/*ie update javascript start*/
var bo_ns_id = 0;

function startIeFix(){  
    if(isIE()){    
     document.write('<div style="display: none;" id="bo_ns_id_' + bo_ns_id + '">');  
    }
}

function endIeFix(){  
    if(isIE()){    
        document.write('</div>');    
        var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);    
        /*if(theObject.firstChild.data){      
            theObject.firstChild.removeAttribute('data');    
        }*/ 
       
        var theParams = theObject.getElementsByTagName("param");    
        var theParamsLength = theParams.length;  
          
        for (var j = 0; j < theParamsLength; j++) {      
            if(theParams[j].name.toLowerCase() == 'flashvars'){        
                var theFlashVars = theParams[j].value;      
            }    
        }  
      
        var theInnnerHTML = theObject.innerHTML;    
        var re = /<param name="FlashVars" value="">/ig;    
        theInnnerHTML = theInnnerHTML.replace(re, "<param name=\"FlashVars\" value=\"" + theFlashVars + "\">");    
        theObject.outerHTML = theInnnerHTML;  
        //alert(theInnnerHTML);
    }
}

function isIE(){  

    var strBrwsr = navigator.userAgent.toLowerCase();  
    if(strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0){   
        return true;  
    }
    else
    {    
        return false;  
    }
}
/*ie update javascript end*/

function MM_reloadPage(init){  //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

var alertTimerId = 0;
var visibleLayerId = 0;

function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }

	obj=MM_findObj(args[i]);
    if (v=='visible')
    {	
		var iframe = document.getElementById('iframe');
		iframe.style.position = 'absolute';
		iframe.style.display = 'block';
		iframe.style.opacity = 0;
		iframe.style.filter = 'alpha(opacity=0)';
		iframe.style.width = obj.offsetWidth;
		iframe.style.height = obj.offsetHeight;
		iframe.style.left = obj.offsetLeft;
		iframe.style.top = obj.offsetTop;

		if(navigator.appName == 'Microsoft Internet Explorer')
		{
			obj.filters.revealTrans.apply();
			obj.filters.revealTrans.play();
		}
    }
	else
	{
		var iframe = document.getElementById('iframe');
		iframe.style.display = 'none';
	}
	obj.style.visibility=v;
	if (visibleLayerId == obj.id) {clearTimeout(alertTimerId);}
	}
}

function MM_showHideLayersSubMenu() { //v6.0
var i,p,v,obj,args=MM_showHideLayersSubMenu.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	
	obj=MM_findObj(args[i]);
    if (v=='visible')
    {   
		var iframe = document.getElementById('iframe');
		iframe.style.position = 'absolute';
		iframe.style.display = 'block';
		iframe.style.opacity = 0;
		iframe.style.filter = 'alpha(opacity=0)';		
		iframe.style.width = obj.offsetWidth;
		iframe.style.height = obj.offsetHeight;
		iframe.style.left = obj.offsetLeft;
		iframe.style.top = obj.offsetTop;
    }
	else
	{
		var iframe = document.getElementById('iframe');
		iframe.style.display = 'none';
	}
	obj.style.visibility=v;
	if (visibleLayerId == obj.id) {clearTimeout(alertTimerId);}
	}
}

function HideLayer(Layer)
{
	Layer.style.visibility='hidden';
	var iframe = document.getElementById('iframe');
	if(iframe.style.top == Layer.offsetTop + 'px')
		iframe.style.display = 'none';
}

function fnStartTimer(Layer)
{
	alertTimerId = setTimeout('HideLayer(' + Layer + ')',10);	
	visibleLayerId = Layer;
}

function fnCompareDate(date1, date2)
{
	var date1UTC;
	var date2UTC;
	var dateDay;
	var dateMonth;
	var dateYear;
	
	dateDay = date1.substr(0, 2);
	dateMonth = date1.substr(3, 2);
	dateMonth = dateMonth - 1;
	dateYear = date1.substr(6, 4);
	
	date1UTC = Date.UTC(dateYear, dateMonth, dateDay);
	
	dateDay = date2.substr(0, 2);
	dateMonth = date2.substr(3, 2);
	dateMonth = dateMonth - 1;
	dateYear = date2.substr(6, 4);

	date2UTC = Date.UTC(dateYear, dateMonth, dateDay);
	
	if (parseFloat(date1UTC) < parseFloat(date2UTC))
		return 1;
	else if (parseFloat(date1UTC) == parseFloat(date2UTC))
		return 0;
	else
		return -1;
}

function captureEnterKey(event) 
{
	if(event.keyCode == 13)
	{
		if (event.preventDefault) {event.preventDefault();}
		else {event.returnValue = false;}
		return false;
	}
}

function fnSearch()
{
	var strURL;
	var strSearch = document.getElementById("Bottom_txtSearch").value;
	var strSearchTrim = strSearch.replace(' ','');

	if (strSearch == '' || strSearchTrim.length == 0)
	{
		alert("Please enter at least one keyword to search");
		document.getElementById("Bottom_txtSearch").focus();
		return 0;
	}
	strURL = "../Search/SiteSearch.aspx?Search=" + strSearch;
	window.parent.location = strURL;
}

function fnSearchonKeyPress(event)
{
	if(event.keyCode == 13)
	{
		fnSearch();
		if (event.preventDefault) {event.preventDefault();}
		else {event.returnValue = false;}
	}
}

function fnOpenCalendarDate(objControl)
{
	window.open('../Common/Calendar.aspx?formname=' + objControl,'calendar_window','width=250,height=240,left=400,top=300');
}

function findFeedbackURL(url, width, height)
{
	window.location.href="/Spices/OtherLinks/FeedBackEntry.aspx";
}
function findDisclaimerURL(url, width, height)
{
	window.location.href="/Spices/ManageContent/ContentView.aspx?ContentID=17";
}
function findContactURL(url, width, height)
{
	window.location.href="/Spices/ManageContent/ContentView.aspx?ContentID=18";
}
function findSitemapURL(url, width, height)
{
	window.location.href="/Spices/OtherLinks/SiteMap.aspx";
}
function findEnquiryURL(url, width, height)
{
	window.location.href="/Spices/OtherLinks/EnquiryParam.aspx";
}
function findSearchURL(url, width, height)
{
	window.location.href="/Spices/Search/SiteSearch.aspx";
	//window.open("http://www.google.com/custom?q=spices&sitesearch=www.itcspices.com");
}
function spicesBusiness()
{
	window.location.href="/Spices/ManageContent/ContentView.aspx?ContentID=2";
}

function Encrypt(strValue,rnd1)
{
		var strNewValue = '';
		var intI = 0;
		intI = parseInt(intI);

        strNewValue = '';
        //alert(strValue);
        for(intI = 0; intI < strValue.length; intI++)
        {
			//alert(strValue.charCodeAt(intI));
			//alert(parseInt(rnd1));
			//alert(strValue.charCodeAt(intI) + parseInt(rnd1));
			//alert(String.fromCharCode(strValue.charCodeAt(intI) + parseInt(rnd1)));
            strNewValue = strNewValue + String.fromCharCode(strValue.charCodeAt(intI) + parseInt(rnd1));
            //alert(strNewValue);
        }
        strNewValue = strNewValue + String.fromCharCode(parseInt(rnd1) + 64);
        //alert(strNewValue);
        return strNewValue;
}