﻿//For Top control Search
//Right Side Zone Smartsearch
function funShowSmartSearch(cur)
{  
}
function funCheckDdl(range)
{    
    try
    {   
        if($('ddlCtg1')!=undefined)
        {
            if($F('ddlCtg1')=='-1')
                alert('Select Level 1 Category');
        }
        else if($F('ddlCtg2')=='-1')
            alert('Select Level 2 Category');
        else
        {   
            var selectedOption = $A($('ddlCtg2').options).find(function(option) { return option.selected; } );
            strText=(selectedOption.text).replace(/ /gi,'-').toLowerCase();
            var strExp = ($('chkExp').checked) ? 'express-shipping/' : '';            
            switch(range)
            {                
                case '0-100':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-below-100-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '101-200':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-between-101-200-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '201-300':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-between-201-300-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '301-500':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-between-301-500-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '501-1000':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-above-500-c-"+$F('ddlCtg2')+".html ";
                    break;                    
                case '0-1000':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-below-1000-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '1001-3000':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-between-1001-3000-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '3001-5000':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-between-3001-5000-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '5001-10000':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-between-5001-10000-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '10001-20000':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-above-10000-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '0-50':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-below-50-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '51-100':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-between-51-100-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '101-200':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-between-101-200-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '201-400':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-between-201-400-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '401-1000':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-above-401-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '0-800':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-below-800-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '801-1600':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-between-801-1600-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '1601-2400':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-between-1601-2400-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '2401-4000':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-between-2401-4000-c-"+$F('ddlCtg2')+".html ";
                    break;
                case '4001-10000':
                    window.location.href=$F('hdnAppPath').toLowerCase()+strText+"/"+strExp+Currency.toLowerCase()+"-price-above-4001-c-"+$F('ddlCtg2')+".html ";
                    break;
            }
        }
    }
    catch(e)
    {        
        alert('@ funCheckDdl');
    }
}

// Begin Whatsnew this week
CursorStyle = "hand";
function findObj(id)
{	
    var obj = null;	
	if (document.getElementById)
		obj = document.getElementById(id);
	else if (document.all)
		obj = document.all[id];
	return obj;
}

function hideAll()
{
	return;	
	var i = 0;
	var obj = null;
	var id = "";
	for (i = 1; i <= 9; i++)
	{
		id = i;
		obj = findObj(id);
		
		if (obj) obj.style.display = "none";
	}
}
function showHide(id)
{
	var obj = findObj(id);		
	if(obj)
	{
		var s = null;
		s = obj.style;		
		// switch on/off the clicked block
		if (s.display == "none") s.display = "block";
		else if (s.display == "block") s.display = "none";
		// swich on/off the last selected block
		if (window.curOpenDiv)
		{
			if (window.curOpenDiv != obj)
			{
				s = window.curOpenDiv.style;
				if (s.display == "block") s.display = "none";
				window.curOpenDiv = obj;
			}
		}
		else
		{
			window.curOpenDiv = obj;
		}
	}
	return false;
}

menu_status = new Array();
var currentOpenItemName=""; 
function CBMenuShow(theid)
{    
    var switch_id = document.getElementById(theid);
    switch_id.className = 'CBMenushow';
    menu_status[theid] = 'CBMenushow';
    currentOpenItemName = theid;
        
}
function CBMenuHide(theid)
{    
    var switch_id = document.getElementById(theid);
    switch_id.className = 'CBMenuhide';
    menu_status[theid] = 'CBMenuhide';
    currentOpenItemName = '';        
}   
    
//EsCbTop.ascx & EsTopLt2.ascx
funClrSearch=function(){     
    if($F('txtProductSearch')=='Product Search')
         $('txtProductSearch').value='';
 } 
funChkPrdSearch=function(){     
    if($F('txtProductSearch')==''||$F('txtProductSearch')=='Product Search' 
        ||funInvalidText($F('txtProductSearch'))==false)
    {
          alert('Search Keyword Missing / Invalid');
          return false;
    }
    else 
        return true;
 }
funGo=function(){   
    if(funChkPrdSearch()==true){           
        window.location.href=$F('hdnAppPath')+"search/" + $F('txtProductSearch').trim().replace(/ /gi,'-').toLowerCase()+".html";  
        }
} 
funInvalidText=function(param){
    flg=0;
    str="";
    spc=""
    arw="";
    for (var i=0;i< param.length;i++){
        cmp="<>?;'%$~`@#^&*()_-=+[]{}\|:;,./"
        tst=param.substring(i,i+1)
        if (cmp.indexOf(tst)>-1){
            flg++;
            str+=" "+tst;
            spc+=tst;
            arw+="^";
        }
        else{arw+=" ";}
    }
    if (flg!=0){
        if (spc.indexOf(" ")>-1) {
            str+=" and a space";
        }
        return false;
    }
 }
 funDefaultSearch=function(e){      
    var key; 
    try{
        key=(e.which) ? e.which : e.keyCode; 
        if(key==13) { 
            $('btnGo').focus(); 
        } 
        return true; 
    }
    catch(e){
        alert('@ funDefaultSearch')
    }    
} 

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
    return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
    return this.replace(/\s+$/,"");
}

function s(divID) 
{
    document.getElementById(divID).style.display = "block";     
}
function h(divID) 
{
    document.getElementById(divID).style.display = "none";     
}
function DivPosition(elementID) 
{
	var element = document.getElementById(elementID);
	if (element != null) 
	{
		element.style.display = "block";
		browserSize = getBrowserSize();
		element.style.position = "absolute";
		element.style.left = browserSize[0]/2 - element.offsetWidth /2;
		element.style.top = browserSize[1]/8 - element.offsetHeight /8;
	}
}

function getBrowserSize() 
{
	var myWidth=0, myHeight=0;
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		/*Non-IE*/
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		/*IE 6+ in 'standards compliant mode'*/
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		/*IE 4 compatible*/
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return new Array(myWidth, myHeight);
}

// for category level page & product type page
function funHideSmartSearch()
{    
    try
    {
        $('divCatalogs').style.display="none";
    }
    catch(e)
    {
        alert('@ funHideSmartSearch');
    }
}    
    
//Session currency change in Category level page
function funCurrChange(Curr)
{       
    try
    {           
        new Ajax.Request($F('hdnAppPath')+'GenetricHandler/SmartSearch.ashx?qStr=Curr|'+Curr,
        {
            method: 'get',
            onSuccess: funCurrChangeSuccess,
            onFailure: funCurrChangeFailure
        });
    }
    catch(e)
    {
        alert('@ funCurrChange');
    }
}
function funCurrChangeSuccess(OrigionalRequest)
{   
    try
    { 
        if (OrigionalRequest.responseText=='Y')            
            window.location.href=document.location.href;
    }
    catch(e)
    {
        alert('@ funSSuccess')
    }
}
function funCurrChangeFailure()
{
    try
    {
        alert(OrigionalRequest.responseText);
    }
    catch(e)
    {
        alert('@ funSFailure');
    }
   
}

// Sign up opens in new window to receive special offers and promotions
function funEmailSignUp()
{   
    try
    {           
        new Ajax.Request($F('hdnAppPath')+'GenetricHandler/SmartSearch.ashx?qStr=SignUp|'+$F('txtEmailSignUp'),
        {
            method: 'get',
            onSuccess: funEmailSignUpSuccess,
            onFailure: funEmailSignUpFailure
        });
    }
    catch(e)
    {
        alert('@ funEmailSignUp');
    }
}
function funEmailSignUpSuccess(OrigionalRequest)
{   
    try
    { 
        if (OrigionalRequest.responseText=='Y')
        {
            alert('Thanks for your query. We will contact you soon.');        
            document.getElementById('txtEmailSignUp').value='';
        }
        else if(OrigionalRequest.responseText=='N')
        {
            alert('You are already registered with us...');
            document.getElementById('txtEmailSignUp').value='';
        }
    }
    catch(e)
    {
        alert('@ funSSuccess')
    }
}
function funEmailSignUpFailure()
{
    try
    {
        alert(OrigionalRequest.responseText);
    }
    catch(e)
    {
        alert('@ funSFailure');
    }   
}

function funValidateEmail(EmailId) 
{    
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if(reg.test(EmailId) == false) 
        return false;    
}

//Footer E-mail exclusives
function emailCheck(param) 
{
   var len=0;   
   len=param.length;   
   if (param.indexOf("@")<1 || param.indexOf(".")<1 || param.indexOf(".")==(len-1))
   {
       return false;
   }   
 }

function funChkValidSignUp()
{
    /**/    
    var ErrMsg=''; 
    if(document.getElementById('txtEmailSignUp').value==''|| emailCheck(document.getElementById('txtEmailSignUp').value)==false || funValidateEmail(document.getElementById('txtEmailSignUp').value)==false)    
        ErrMsg='\n Email Id is Missing/Invalid';
    if(ErrMsg!='')
    {   
        alert(ErrMsg);                    
        return false;            
    }
    else
    {
        funEmailSignUp();
        return true;
    }
}

function divShowHideLeftMenu(child,act,parent1,position){	
var browser = navigator.appName;
var b_version=navigator.appVersion;
//document.getElementById(child).style.display = 'none';
	if (act == "show")
	{
		var p = document.getElementById(parent1);
        var c = document.getElementById(child );
//        p.className = 'activeLeft';
		c["at_position"]="x";
        var top1  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
        var left = (c["at_position"] == "x") ? p.offsetWidth -11 : 0;
               for (; p; p = p.offsetParent)
        {
            top1  += p.offsetTop;
            left += p.offsetLeft;
        }
        
        if(browser.match("Microsoft Internet Explorer") == "Microsoft Internet Explorer"){
		   var ieObjdiv = document.getElementById(child);
		   ieObjdiv.className = "";
//		   ieObjdiv.className = "subMenuie";  
		}
        
		//alert("top["+top+"]&left["+left+"]");
        c.style.display = 'block'; 
        c.style.position   = "absolute";
        c.style.top        = top1 +'px';
        //c.style.left       = left+'px';
        c.style.left       = '190px';
        c.style.visibility = "visible";
        c.style.zIndex = '10';
        
	    }
	   else if (act == "hide")
	   {
		document.getElementById(child).style.display = 'none';
		document.getElementById(child).style.visibility = 'hidden';
		var p = document.getElementById(parent1);
//		 p.className = 'dactiveLeft';
	   }
	   
}
/* ----------------------------------------------------------------------------------------------------- */

function funSortBy(pSortBy, pStPageVal, pEndPageVal,pPageId)
{    
    var vPageId=pPageId;     
    if(vPageId != undefined)
        $('hdnCurrPage').value='a_'+pPageId;    
    else if(vPageId == undefined)
        $('hdnCurrPage').value='a_1';
    $('hdnStPage').value=pStPageVal;
    $('hdnEndPage').value=pEndPageVal;  
    var vPageId2=pPageId;      
    if(vPageId2 != undefined)
        $('hdnCurrPage2').value='a2_'+pPageId;    
    else if(vPageId2 == undefined)
        $('hdnCurrPage2').value='a2_1';        
    try
    {
        $('dvProducts').innerHTML='<center><img id="imgLoading" src="/image/EsLoading.gif" alt="Loading..." /></center>';
        if(pSortBy !='N')
        {
            $('hdnSortBy').value=pSortBy;            
            pSortBy=$('hdnSortBy').value;        
            var qStr='';
            switch($F('hdnMode'))
            { 
                case 'Def':
                    qStr='PrdsV2|'+pSortBy+'|Def|'+$F('hdnCtg1id')+'|'+$F('hdnCtg2id')+'|'+$F('hdnCtg3id')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'shopby':
                    qStr='PrdsV2|'+pSortBy+'|shopby|'+$F('hdnPrdType')+'|'+$F('hdnSBClass')+'|'+$F('hdnSBSubClass')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'shopby-price':
                    qStr='PrdsV2|'+pSortBy+'|shopby-price|'+$F('hdnPrdType')+'|'+$F('hdnStPrice')+'|'+$F('hdnEndPrice')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'fltser-new':
                    qStr='PrdsV2|'+pSortBy+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'fltser-sale':
                    qStr='PrdsV2|'+pSortBy+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'fltser-express':
                    qStr='PrdsV2|'+pSortBy+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'fltser-customSize':                   
                    var qStr='PrdsV2|'+pSortBy+'|customSize|'+$F('hdnPrdType')+'|'+$F('hdnSize')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'bstslr':
                    qStr='PrdsV2|'+pSortBy+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'mstvwd':
                    qStr='PrdsV2|'+pSortBy+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'clrnsale':
                    qStr='PrdsV2|'+pSortBy+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'ftrprd':
                    qStr='PrdsV2|'+pSortBy+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'ser':
                    qStr='PrdsV2|'+pSortBy+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$F('hdnSerVal')+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'wsh':
                    qStr='PrdsV2|'+pSortBy+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'new':
                    qStr='PrdsV2|'+pSortBy+'|'+$F('hdnMode')+'|new|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'DeleDate':  
                    $('hdnMode').value='DeleDate';              
                    var qStr='PrdsV2|'+pSortBy+'|DeleDate|'+$F('hdnPrdType')+'|'+DeleDate+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnCurrPage').value+'|'+$('hdnPrdsCnt').value+'|';
                    break;   
                case 'RMPrdSize':  
                    $('hdnMode').value='RMPrdSize';              
                    var qStr='PrdsV2|'+pSortBy+'|RMPrdSize|'+$F('hdnPrdType')+'|'+RMPrdSize+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnCurrPage').value+'|'+$('hdnPrdsCnt').value+'|';
                    break;                  
                case 'fltser-offer':
                    qStr='PrdsV2|'+pSortBy+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;       
            }            
            funCallHandlerPrdsV2(qStr);             
//             window.location.href = window.location.href;
        }
        else if(pSortBy =='N')
        {                  
            var qStr='';
            switch($F('hdnMode'))
            {
                case 'Def':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|Def|'+$F('hdnCtg1id')+'|'+$F('hdnCtg2id')+'|'+$F('hdnCtg3id')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'shopby':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|shopby|'+$F('hdnPrdType')+'|'+$F('hdnSBClass')+'|'+$F('hdnSBSubClass')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'shopby-price':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|shopby-price|'+$F('hdnPrdType')+'|'+$F('hdnStPrice')+'|'+$F('hdnEndPrice')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'fltser-new':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'fltser-sale':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'fltser-express':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'fltser-customSize':                   
                    var qStr='PrdsV2|'+$('hdnSortBy').value+'|customSize|'+$F('hdnPrdType')+'|'+$F('hdnSize')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';                    
                    break;
                case 'bstslr':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'mstvwd':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'clrnsale':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'ftrprd':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'ser':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$F('hdnSerVal')+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'wsh':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'new':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|'+$F('hdnMode')+'|new|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;
                case 'DeleDate':          
                    $('hdnMode').value='DeleDate';           
                    var qStr='PrdsV2|'+$('hdnSortBy').value+'|DeleDate|'+$F('hdnPrdType')+'|'+DeleDate+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;  
                case 'RMPrdSize':  
                    $('hdnMode').value='RMPrdSize';              
                    var qStr='PrdsV2|'+$('hdnSortBy').value+'|RMPrdSize|'+$F('hdnPrdType')+'|'+RMPrdSize+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnCurrPage').value+'|'+$('hdnPrdsCnt').value+'|';
                    break;   
                case 'fltser-offer':
                    qStr='PrdsV2|'+$('hdnSortBy').value+'|'+$F('hdnMode')+'|'+$F('hdnPrdType')+'|'+pStPageVal+'|'+pEndPageVal+'|'+$('hdnPrdsCnt').value+'|';
                    break;            
            }
            funCallHandlerPrdsV2(qStr);             
//         window.location = window.location.href;
        } 
        
    }
    catch(e)
    {
        alert('@ funShortBy');
    }
}

function funGenDtl(pDivId, pPrdId, pGen)
{    
    try
    {
        var qStr='';
        qStr='Gen|'+pDivId+'|'+pPrdId+'|'+pGen;        
        funCallHandlerPrdsV2(qStr);
    }
    catch(e)
    {
        alert('@ funGenDtl');
    }
}
function funWishlistOpr(pPrdId, pOpr)
{
    try
    {
        var qStr='';
        var strRem='';
        if(pOpr=='wsh-del')
        {
            strRem=confirm('Are you sure to remove this product from your wish list');
            if(strRem)
            {
                qStr='PrdsV2||wsh-del|'+pPrdId+'|1|20|0';
                funCallHandlerPrdsV2(qStr);
            }
            else 
                return false;           
        }
        if(pOpr=='wsh-add')
        {
            strRem= confirm('Are you sure to add this product in your wish list');
            if(strRem)
            {
                qStr='PrdsV2||wsh-add|'+pPrdId+'|1|20|0';
                funCallHandlerPrdsV2(qStr);
            }
            else 
                return false;
        }        
    }
    catch(e)
    {
        alert('@ funWishlistOpr');
    }
}
function funCallHandlerPrdsV2(qStr)
{    
//    debugger;
//    var vRandom='';
//    var d=new Date();
//    vRandom=d.getSeconds();    
    try
    {   
        new Ajax.Request($F('hdnAppPath')+'GenetricHandler/SmartSearch.ashx?qStr='+qStr,
            {
                method: 'get',
                onSuccess: funPrdsV2Success,
                onFailure: funPrdsV2Failure
            });
    }
    catch(e)
    {
        alert('@ funCallHandlerPrdsV2');
    }
}

function funPrdsV2Success(OrigionalRequest)
{
    try
    {   
        var arrResult=new Array();        
        arrResult=OrigionalRequest.responseText.split('|');        
        if(arrResult.length>0)
        {
            if(arrResult[0]!='Gen' && arrResult[0]!='wshopr' && arrResult[0]!='Req' && arrResult[0]!='B2B' && arrResult[0]!='NoPrds')
            {                                
                $('dvProducts').innerHTML = OrigionalRequest.responseText.split('|')[0];    
                funLazyLoad();
                //scroll to top start
                $j(function () {
                $j(".scrlTop").click(function () {
                     $j("html, body").animate({
                         scrollTop: "50px"
                     },
                     1500);
                     return false;
                    });
                }); 
                //scroll to top end
                if((window.location.href).search(/c-hi.html/)!= -1)
                {
                    $('dvPrdTabDtl').style.display='block';
                    if($('dvPrdTabDtl')!=undefined)
                        var vPrdTabDtl = new Spry.Widget.TabbedPanels('dvPrdTabDtl');     
                }
                else if((window.location.href).search(/c-hi.html/)== -1)
                {
                    if((window.location.href).search(/homeindia/)!= -1)
                        $('dvPrdTabDtl').style.display='none';
                }
            }
            else if(arrResult[0]=='NoPrds')
            {
                $('dvProducts').innerHTML = OrigionalRequest.responseText.split('|')[1];
                funLazyLoad();
                //scroll to top start
                $j(function () {
                $j(".scrlTop").click(function () {
                     $j("html, body").animate({
                         scrollTop: "50px"
                     },
                     1500);
                     return false;
                    });
                }); 
                //scroll to top end
            }
            if(arrResult[0]=='Gen')
            {
                $(arrResult[1]).innerHTML = arrResult[2].toString();     
                $(arrResult[1]).style.display='block';
            }
            if(arrResult[0]=='wshopr')
            {
                window.location.href = window.location.href;                
            }
            if($F('hdnCurrPage') != undefined && $F('hdnCurrPage') != '')
            {              
                $($F('hdnCurrPage')).className='active'; 
                $($F('hdnCurrPage2')).className='active';
            }            
            if($F('hdnCurrPage2') != undefined && $F('hdnCurrPage2') != '')
            {
                $($F('hdnCurrPage2')).className='active';  
                $($F('hdnCurrPage')).className='active';              
            }
            if(arrResult[0]=='Req')
            {
                alert('Your request has been sent for the product code: '+arrResult[1]);
            }
            if(arrResult[0]=='B2B')
            {
                if(arrResult[1]!='Y')
                    alert(arrResult[1]);
                else if(arrResult[1]=='Y')
                    window.location.href=document.location.href;                    
            }     
            var Currency=$F('hdnCurrency');                
            Cur=document.getElementsByName('CtgCurrency');
            for (var i = 0; i < Cur.length; i++) 
            {
                if (Cur[i].value==Currency) 
                {	
                    Cur[i].checked=true;
                    break;
                }
            }  
            if (arrResult[0]!='Gen' && arrResult[0]!='B2B' && arrResult[0]!='wshopr' && arrResult[0]!='NoPrds')
            {
                switch($F('hdnSortBy'))
                {
                    case 'PRICE-LH':
                        $('priceLtoH').replace('<span>$$ low-high</span>');
                        break;
                    case 'PRICE-HL':
                        $('priceHtoL').replace('<span>high-low</span>');
                        break;
                    case 'NEWYN':
                    case 'CREATEDATE':
                        $('newarrivals').replace('<span>what’s new</span>');
                        break;
                    case 'READY':
                        $('expressship').replace('<span>Ready to Ship</span>');
                        break;
                    case 'SALE':
                        $('sale').replace('<span>Sale</span>');
                        break;
                    case 'EXCLU':
                        $('exclusive').replace('<span style="border-left:0px">Exclusive</span>');
                        break;
                     case 'OFFER3F2':
                         $('offer3f2').replace('<span>3 For 2 Offer</span>');
                        break;
                }
            }
        }
//        window.location = window.location.href;      
    }
    catch(e)
    {
//        alert('@ funPrdsV2Success')
    }    
}

function funPrdsV2Failure(OrigionalRequest)
{
    try
    {
        alert(OrigionalRequest.responseText);
    }
    catch(e)
    {
        alert('@ funPrdsV2Failure');
    }
   
}

function funImgPosition(pEvent,pImgDivId, pImgSrc,pImgId)
{
    try
    {
        $(pImgId).src="http://www.chennaibazaar.com/image/EsLoadingSmall.gif";
        var dom = (document.getElementById) ? true : false;
        var ns5 = (!document.all && dom || window.opera) ? true: false;
        var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		var mouseX = (ns5)? pEvent.pageX: window.event.clientX + standardbody.scrollLeft;
		var mouseY = (ns5)? pEvent.pageY: window.event.clientY + standardbody.scrollTop;
        
        var a=window.innerWidth;
        var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
	    var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
	    if((mouseX+400)>winWd)
	        $(pImgDivId).style.left=winWd-(mouseX+400)+'px';	    
        $j('#'+pImgDivId).show('slow');
         $(pImgId).src=pImgSrc;
    }
    catch(e)
    {
        alert('@ funImgPosition');
    }
}
function funOpenSare(pShare)
{
    switch(pShare)
    {
        case 'fb':
            window.open("http://www.facebook.com/share.php?u="+window.location.href,"mywindow");
            break;
        case 'tr':
            window.open("http://twitter.com/home?status=Enjoy this stunning outfit at "+window.location.href,"mywindow");
            break;
        case 'bz':
            window.open("http://buzz.yahoo.com/buzz?targetUrl="+window.location.href,"mywindow");
            break;
        case 'dg':
            window.open("http://digg.com/submit?url="+window.location.href,"mywindow");
            break;
    }            
}

function funOSRequest(pPrdCode,pCtg3Id)
{
    try
    {
        $('dvOSReqForm').style.display='block';
        $('spnReqPrdCode').innerHTML=pPrdCode;  
        $('hdnReqPCode').value=pPrdCode;       
        $('hdnReqCtgId').value=pCtg3Id;               
    }
    catch(e)
    {
        aletr('@ funOSRequest');
    }
}

function funOSRequestMail()
{   
    var vErrMsg='',vPrdCode='';
    try
    {   
        if($F('txtPRName')=='')
            vErrMsg='\nName';            
        if($F('txtPREmailId')==''||emailCheck($F('txtPREmailId'))==false)        
            vErrMsg=vErrMsg + '\nEmail Id Missing/Invalid'; 
        if($F('txtPRCountry')=='')
            vErrMsg=vErrMsg + '\nCountry';                  
        if(vErrMsg!='')
        {
            alert('Please submit the below required details.\r\n-------------------------------------------------\r'+vErrMsg);             
            return false;
        }
        else
        {  
            vQStr='PrdsV2||PrdOsReq|'+$F('hdnReqPCode')+'|'+$F('hdnReqCtgId')+'|'+$F('txtPREmailId')+'|'+$F('txtCmts')+'^'+$F('txtPRName')+'^'+$F('txtPREmailId')+'^'+$F('txtPRPhone')+'^'+$F('txtPRCountry')+'|'; 
            $('dvOSReqForm').hide();
            funCallHandlerPrdsV2(vQStr); 
        }   
    }
    catch(e)
    {
        alert('@ funOSRequestMail');
    }
}
var DeleDate='';
function funDeleDate(pType,pDeleDate)
{
    try
    {
        if(pDeleDate=='')
        {
            alert('Enter the date');
            return false;
        }
        else 
        {
            if(isDate(pDeleDate))
            {
                DeleDate=pDeleDate;
                $('hdnMode').value='DeleDate';
                $('hdnPrdType').value=pType;
                var qStr='PrdsV2|'+$('hdnSortBy').value+'|DeleDate|'+pType+'|'+pDeleDate+'|1|20|';                
                funCallHandlerPrdsV2(qStr);
            }       
        }
        
    }
    catch(e)
    {
        alert('@ funDeleDate');
    }
}
var RMPrdSize='';
function funRMPrdSize(pType,pSize)
{
    try
    {    
        RMPrdSize=pSize;
        $('hdnMode').value='RMPrdSize';
        $('hdnPrdType').value=pType;
        var qStr='PrdsV2|'+$('hdnSortBy').value+'|RMPrdSize|'+pType+'|'+pSize+'|1|20|';
        funCallHandlerPrdsV2(qStr);        
    }
    catch(e)
    {
        alert('@ funRMPrdSize');
    }
}

/**
 * DHTML date validation script. 
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

/* ----------------------------------------------------------------------------------------------------- */

function divShowRequest(act,parent1,pPrdCode,pCtg3Id,pEvent,position)
{   
    var browser = navigator.appName;
    var b_version=navigator.appVersion;
	if (act == "show")
	{
	    $('txtCmts').value='';
	    $('txtPRName').value='';
	    $('txtPREmailId').value='';
	    $('txtPRPhone').value='';
	    $('txtPRCountry').value='';
	    $('spnReqPrdCode').innerHTML=pPrdCode;  
        $('hdnReqPCode').value=pPrdCode;       
        $('hdnReqCtgId').value=pCtg3Id;  
		var p = document.getElementById(parent1);
        var c = document.getElementById('dvOSReqForm');
        var dom = (document.getElementById) ? true : false;
        var ns5 = (!document.all && dom || window.opera) ? true: false;
        var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		var mouseX = (ns5)? pEvent.pageX: window.event.clientX + standardbody.scrollLeft;
		var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
		c["at_position"]="x";
        var top1  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
        if((mouseX+550)>winWd)
             var left=winWd-(mouseX+400)+'px';
        else
        var left = (c["at_position"] == "x") ? p.offsetWidth -11 : 0;
               for (; p; p = p.offsetParent)
        {
            top1  += p.offsetTop;
            left += p.offsetLeft;
        }
        
        if(browser.match("Microsoft Internet Explorer") == "Microsoft Internet Explorer")
        {
		   var ieObjdiv = document.getElementById('dvOSReqForm');
		   //ieObjdiv.className = "";
		}
        c.style.display = 'block'; 
        c.style.position   = "absolute";
        c.style.top        = top1 +'px';
        c.style.left       = left+'px';
        c.style.visibility = "visible";
        c.style.zIndex = '10';        
    }  
}


function funDefSortBy()
{    
    if($F('hdnCurrPage')!='')
    {
        $($F('hdnCurrPage')).className='active';   
//        funSortBy('', $('hdnStPage').value, $('hdnEndPage').value,$F('hdnCurrPage'));
    }
    if($F('hdnCurrPage2')!='') 
        $($F('hdnCurrPage2')).className='active';
    switch($F('hdnSortBy'))
    {
        case 'PRICE-LH':
            if($('priceLtoH')!=null)
                $('priceLtoH').replace('<span>$$ low-high</span>');
            break;
        case 'PRICE-HL':
            if($('priceHtoL')!=null)
                $('priceHtoL').replace('<span>high-low</span>');
            break;
        case 'NEWYN':
        case 'CREATEDATE':
            if($('newarrivals')!=null)
                $('newarrivals').replace('<span>what’s new</span>');
            break;
        case 'READY':
            if($('expressship')!=null)
                $('expressship').replace('<span>Ready to Ship</span>');
            break;
         case 'SALE':
            $('sale').replace('<span>Sale</span>');
            break;
        case 'EXCLU':
            if($('exclusive')!=null)
                $('exclusive').replace('<span style="border-left:0px">Exclusive</span>');
            break;
        case 'OFFER3F2':
            if($('offer3f2')!=null)
                $('offer3f2').replace('<span>3 For 2 Offer</span>');
    }    
    if((window.location.href).search(/c-hi.html/)!= -1)
    {
        $('dvPrdTabDtl').style.display='block';
        if($('dvPrdTabDtl')!=undefined)
            var vPrdTabDtl = new Spry.Widget.TabbedPanels('dvPrdTabDtl');     
    }
    else if((window.location.href).search(/c-hi.html/)== -1)
    {
        if((window.location.href).search(/homeindia/)!= -1)
            $('dvPrdTabDtl').style.display='none';
    }
    funPrdsPageLoad();
}


function funMarginPos(pEvent,pMarginDivId)
{
    try
    {
        var dom = (document.getElementById) ? true : false;
        var ns5 = (!document.all && dom || window.opera) ? true: false;
        var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		var mouseX = (ns5)? pEvent.pageX: window.event.clientX + standardbody.scrollLeft;
		var mouseY = (ns5)? pEvent.pageY: window.event.clientY + standardbody.scrollTop;
        
        var a=window.innerWidth;
        var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
	    var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
	    if((mouseX+400)>winWd)
	        $j('#'+pMarginDivId).css('left',winWd-(mouseX+400));
        $j('#'+pMarginDivId).show('slow');                
    }
    catch(e)
    {
        alert('@ funMarginPos');
    }
}
var vCnt=0;
function funSortByBackToPage(pSortBy, pStPageNo, pEndPageNo, pCurrPageId,pCnt)
{    
    try
    {
        pCnt+=1;
        alert(vCnt);
//        funSortBy(pSortBy,pStPageNo,pEndPageNo,pCurrPageId);        
    }
    catch(e)
    {
        //alert('@ funSortByBackToPage');
    }
}
/*--------------------------------------------------------------------------------*/
//for B2B festival like eid, etc..,
function funB2BFestivalValid()
{  
    try
    {
        var ErrMsg='';     
        if(document.getElementById('txtName').value=='')
            ErrMsg+='\n Name '
        if(document.getElementById('txtStoreName').value=='')
            ErrMsg+='\n Store / Bussiness Name ';
        if(document.getElementById('txtAddr1').value=='')
            ErrMsg+='\n Address 1 ';
        if(document.getElementById('txtCountry').value=='')
            ErrMsg+='\n Country ';
        if(document.getElementById('txtState').value=='')
            ErrMsg+='\n State ';
        if(document.getElementById('txtCity').value=='')
            ErrMsg+='\n City ';
        if(document.getElementById('txtPhone').value=='')
            ErrMsg+='\n Phone ';                           
        if(document.getElementById('txtEmail').value==''|| emailCheck(document.getElementById('txtEmail').value)==false || funValidateEmail(document.getElementById('txtEmail').value)==false)    
            ErrMsg+='\n Email-ID Missing/Invalid';       
        if(ErrMsg!='')
        {  
            alert('Please submit the below required details.\r\n-------------------------------------------------\r'+ErrMsg);                      
            return false;            
        }
        else
        {
            funCallHandlerB2BFestival();
            return true;
        }
    }
    catch(e)
    {
        //alert('@ funB2BFestivalValid')
    }
}

function funCallHandlerB2BFestival()
{    
    try
    {   
        var qStr='';
        qStr='B2BFestival'+'|'+$F('txtName')+'|'+$F('txtStoreName')+'|'+$F('txtAddr1')+'|'+$F('txtAddr2')+'|'+$F('txtCountry')+'|'+$F('txtState')+'|'+$F('txtCity')+'|'+$F('txtPinCode')+'|'+$F('txtPhone')+'|'+$F('txtMobile')+'|'+$F('txtEmail')+'|';
        new Ajax.Request('/GenetricHandler/SmartSearch.ashx?qStr='+qStr,
            {
                method: 'get',
                onSuccess: funB2BFestivalSuccess,
                onFailure: funB2BFestivalFailure
            });
    }
    catch(e)
    {
        alert('@ funCallHandlerB2BFestival');
    }
}

function funB2BFestivalSuccess(OrigionalRequest)
{
    try
    {          
        var arrResult=new Array();        
        arrResult=OrigionalRequest.responseText.split('|');        
        if(arrResult.length>0)
        {
           alert('Hi '+arrResult[1] +' you have successfully registered!...');
           window.location.href='http://wholesale.cbazaar.com/';
        }       
    }
    catch(e)
    {
//        alert('@ funB2BFestivalSuccess')
    }    
}

function funB2BFestivalFailure(OrigionalRequest)
{
    try
    {
        alert(OrigionalRequest.responseText);
    }
    catch(e)
    {
        alert('@ funB2BFestivalFailure');
    }
   
}
/*--------------------------------------------------------------------------------------------------------------*/
function funClrLogin(pMode)
{
    try
    {
        if(pMode=='focus')
        {
            if($F('txtExistLogin')=='Login Id')
                $('txtExistLogin').value='';
        }
        else if(pMode=='lost-focus')
        {
            if($F('txtExistLogin')=='')
                $('txtExistLogin').value='Login Id';
        }
    }
    catch(e)
    {
        alert('@ funClrLogin');
    }
}

function funClrLoginPwd(pMode)
{
    try
    {
        if(pMode=='focus')
        {
            if($F('txtExistPwd')=='Password')
                $('txtExistPwd').value='';
        }
        else if(pMode=='lost-focus')
        {
            if($F('txtExistPwd')=='')
                $('txtExistPwd').value='Password';
        }
    }
    catch(e)
    {
        alert('@ funClrLogin');
    }
}

function funHI(pMode)
{
    var ErrMsg='';
    var qStr='';
    switch(pMode)
    {
        case 'HILogin':            
            if(($('txtExistLogin').value).trim()=='')    
                ErrMsg='\n Login-ID Missing/Invalid';
            if(($('txtExistPwd').value).trim()=='')
                ErrMsg=ErrMsg + '\n Password';    
            if(ErrMsg!='')
            {  
                alert('Please submit the below required details.\r\n------------------------------------------\r'+ErrMsg);                      
                return false;            
            }
            else
            {
                var vRememberMe='0';
                if($('chkRememberMe')!=null)                
                    vRememberMe=($('chkRememberMe').checked) ? '1' : '0'
                qStr='HI|HILogin|'+$F('txtExistLogin')+'|'+$F('txtExistPwd')+'|'+vRememberMe+'|';
            }
            break;
        case 'HIRegistration':         
            var ErrMsg='';
            if($('txtHILogin').value=='' || emailCheck($('txtHILogin').value)==false || InvalidLogin($('txtHILogin').value)==false)    
                ErrMsg='\n Login-ID Missing/Invalid';
            if($('txtHIName').value=='' || numericCheck($('txtHIName').value)!=false ||(funInvalidSplSymbols($('txtHIName').value)==false))    
                ErrMsg=ErrMsg=ErrMsg +'\n Name Missing/Invalid';    
            if($('txtHIName').value.length>50)
                ErrMsg=ErrMsg=ErrMsg +'\n Name should not exceed 50 characters';                                    
            if($('txtHIPassword').value=='')
                ErrMsg=ErrMsg=ErrMsg +'\n Password';                                    
            if($('txtHIConfirmPassword').value=='')
                ErrMsg=ErrMsg=ErrMsg +'\n Confirm Password';            
            if(ErrMsg!='')
            {   
                alert('Please submit the below required details.\r\n-------------------------------------------------\r'+ErrMsg);                      
                return false;            
            }
            else
            {
                qStr='HI|HIRegistration|'+$F('txtHILogin')+'|'+$F('txtHIName')+'|'+$F('txtHIPassword')+'|';                 
            }        
            break;        
    }
    funHICallHandler(qStr);
}
function funChkHIPwdMisMtch()
{   
    if(document.getElementById('txtHIPassword').value!=document.getElementById('txtHIConfirmPassword').value)    
        alert('Password Mismatch');  
}
function funChkHIPwdLen()
{
    var pwdLen;
    pwdLen=document.getElementById('txtHIPassword').value;        
    if(pwdLen.length<6 || pwdLen.length>20)   
        alert('Password should be minimum of 6 & maximum of 20 characters');
}
function funHICallHandler(qStr)
{
    var vAppDomain;    
    try
    {   
        if((window.location.href).indexOf('EStoreUI') > -1)
            vAppDomain='/EStoreUI';
        else
            vAppDomain='';
        new Ajax.Request(vAppDomain+'/GenetricHandler/SmartSearch.ashx?qStr='+qStr,
            {
                method: 'get',
                onSuccess: funHISuccess,
                onFailure: funHIFailure
            });
    }
    catch(e)
    {
        alert('@ funHICallHandler');
    }
}

function funHISuccess(OrigionalRequest)
{
    try
    {        
        var arrResult=new Array();        
        arrResult=OrigionalRequest.responseText.split('|');        
        if(arrResult.length>0)
        {
            if(arrResult[0]=='B2C')
            {
                if(arrResult[1]=='Y')
                {
                    alert('Hi, '+arrResult[2]);
                    window.location.href='/default.aspx';
                    return true;
                }
                else  if(arrResult[1]=='N')
                {
                    alert('Hi, '+arrResult[2]);
                    return true;
                }
            }
            else if(arrResult[0]=='HIRegistration')
            {
                if(arrResult[1]=='Exists')
                    alert('Hi, '+arrResult[2]);
                else if(arrResult[1]=='NotExists')
                {
                    alert('Hi, '+arrResult[2]);
                    window.location.href='/default.aspx';
                }
                return true;
            }                
        }
    }
    catch(e)
    {
//        alert('@ funHISuccess')
    }    
}

function funHIFailure(OrigionalRequest)
{
    try
    {
        alert(OrigionalRequest.responseText);
    }
    catch(e)
    {
        alert('@ funHIFailure');
    }
}

//product type based menu function show hide the dive
function funShowHide(pEvent,pMode,pDiv,pLi)
{
    try
    {
        if(pMode=='S')
        {         
            document.getElementById(pDiv).style.display='block';
            document.getElementById(pDiv).style.position='absolute';
            document.getElementById(pDiv).style.top='28px';			
        }
        else if(pMode=='H')
        {
            document.getElementById(pDiv).style.display='none';
            document.getElementById('liSaree').className='tabmenu';
            document.getElementById('liSalwar').className='tabmenu';
            document.getElementById('liKurti').className='tabmenu';
            document.getElementById('liKids').className='tabmenu';
            document.getElementById('liLehenga').className='tabmenu';
            document.getElementById('liMensWear').className='tabmenu';	                  
            document.getElementById('liJewelry').className='tabmenu';	            
        }
        else if(pMode=='OnlyShow')
        {
            document.getElementById(pDiv).style.display='block';
            document.getElementById(pLi).className='liHover';	            
        }
    }
    catch(e)
    {
        alert('@ funShowHide');
    }
}

function funRemoveClassification(pClassi)
{
    try
    {
        var vClassi=pClassi.replace(/ /gi,'_').toLowerCase();
        window.location.href=window.location.href.replace(vClassi,'').replace('/-','/').replace('--','-').replace('-/c-sb.html','/c-sb.html').replace('//c-sb.html','/c-sb.html');        
    }
    catch(e)
    {
        alert('@ funRemoveClassification');
    }
}
function funCustSizeUrl(pCustSize)
{
    try
    {
        if(window.location.href.indexOf('c-sb.html')>1)
        {
            var arrUrl=new Array();
            var vUrl='';
            if((window.location.href).indexOf('-price-')>1 && (window.location.href).indexOf('delivery_days')==-1)
            {            
                vUrl=window.location.href.slice(0,window.location.href.indexOf('-price-')-3);
                vUrl+=pCustSize+'-';
                vUrl+=window.location.href.slice(window.location.href.indexOf('-price-')-3,window.location.href.lastIndexOf('.html')+5);
                window.location.href=vUrl.replace('/-','/').replace('-/','/');
            }
            else if((window.location.href).indexOf('-price-')==-1 && (window.location.href).indexOf('delivery_days')>1)
            {               
                vUrl+=window.location.href.replace(window.location.href.slice(window.location.href.indexOf('delivery_days')-3,window.location.href.lastIndexOf('.html')+5),
                pCustSize+'-'+window.location.href.slice(window.location.href.indexOf('delivery_days')-3,window.location.href.lastIndexOf('.html')+5));
                window.location.href=vUrl.replace('/-','-').replace('-/','-');
            }
            else if((window.location.href).indexOf('-price-')>1 && (window.location.href).indexOf('delivery_days')>1)
            {            
                vUrl=window.location.href.slice(0,window.location.href.indexOf('-price-')-3);
                vUrl+=pCustSize+'-';
                vUrl+=window.location.href.slice(window.location.href.indexOf('-price-')-3,window.location.href.lastIndexOf('.html')+5);
                window.location.href=vUrl.replace('/-','/').replace('-/','/');
            }
            else if((window.location.href).indexOf('-price-')==-1 && (window.location.href).indexOf('delivery_days')==-1 &&
            (   window.location.href.indexOf('occasion')>-1 || window.location.href.indexOf('color')>-1 || window.location.href.indexOf('fabric')>-1 || 
                window.location.href.indexOf('films')>-1 || window.location.href.indexOf('celebrities')>-1 || window.location.href.indexOf('style')>-1 ||
                window.location.href.indexOf('art_style')>-1 || window.location.href.indexOf('speciality')>-1))
                window.location.href=window.location.href.replace('/c-sb.html','-'+pCustSize+'/c-sb.html').replace('/-','/').replace('-/','/');        
            else
                window.location.href=window.location.href.replace('/c-sb.html','/'+pCustSize+'/c-sb.html').replace('/-','/').replace('-/','/');
        }
        else if(window.location.href.indexOf('c-sb.html')==-1)
        {
            window.location.href='/'+$F('hdnPrdType').replace(' ','-')+'/'+pCustSize+'/c-sb.html';
        }
    }
    catch(e)
    {
        alert('@ funCustSizeUrl');
    }
}
function funRMSizeUrl(pPrdType,pRMSize)
{
    try
    {
        if(window.location.href.indexOf('c-sb.html')>1)
        {
            var arrUrl=new Array();
            var vUrl='';
            if((window.location.href).indexOf('-price-')>1 && (window.location.href).indexOf('delivery_days')==-1)
            {            
                vUrl=window.location.href.slice(0,window.location.href.indexOf('-price-')-3);
                vUrl+=pRMSize+'-';
                vUrl+=window.location.href.slice(window.location.href.indexOf('-price-')-3,window.location.href.lastIndexOf('.html')+5);
                window.location.href=vUrl.replace('/-','/').replace('-/','/');
            }
            else if((window.location.href).indexOf('-price-')==-1 && (window.location.href).indexOf('delivery_days')>1)
            {               
                vUrl+=window.location.href.replace(window.location.href.slice(window.location.href.indexOf('delivery_days')-3,window.location.href.lastIndexOf('.html')+5),
                pRMSize+'-'+window.location.href.slice(window.location.href.indexOf('delivery_days')-3,window.location.href.lastIndexOf('.html')+5));
                window.location.href=vUrl.replace('/-','-').replace('-/','-');
            }
            else if((window.location.href).indexOf('-price-')>1 && (window.location.href).indexOf('delivery_days')>1)
            {            
                vUrl=window.location.href.slice(0,window.location.href.indexOf('-price-')-3);
                vUrl+=pRMSize+'-';
                vUrl+=window.location.href.slice(window.location.href.indexOf('-price-')-3,window.location.href.lastIndexOf('.html')+5);
                window.location.href=vUrl.replace('/-','/').replace('-/','/');
            }
            else if((window.location.href).indexOf('-price-')==-1 && (window.location.href).indexOf('delivery_days')==-1 &&
            (   window.location.href.indexOf('occasion')>-1 || window.location.href.indexOf('color')>-1 || window.location.href.indexOf('fabric')>-1 || 
                window.location.href.indexOf('films')>-1 || window.location.href.indexOf('celebrities')>-1 || window.location.href.indexOf('style')>-1 ||
                window.location.href.indexOf('art_style')>-1 || window.location.href.indexOf('speciality')>-1))
                window.location.href=window.location.href.replace('/c-sb.html','-'+pRMSize+'/c-sb.html').replace('/-','/').replace('-/','/');
            else
                window.location.href=window.location.href.replace('/c-sb.html','/'+pRMSize+'/c-sb.html').replace('/-','/').replace('-/','/');
        }
        else if(window.location.href.indexOf('c-sb.html')==-1)
        {
            window.location.href='/'+$F('hdnPrdType').replace(' ','-')+'/'+pRMSize+'/c-sb.html';
        }
    }
    catch(e)
    {
        alert('@ funRMSizeUrl');
    }
}
function funDeliDaysUrl(pDeliDaysUrl)
{
    try
    {    
        if(window.location.href.indexOf('c-sb.html')>1)
        {   
            if((window.location.href).indexOf('occasion')>0 || (window.location.href).indexOf('color')>0 || (window.location.href).indexOf('fabric')>0
                || (window.location.href).indexOf('style')>0 || (window.location.href).indexOf('art_style')>0 || (window.location.href).indexOf('celebrities')>0
                || (window.location.href).indexOf('films')>0 || (window.location.href).indexOf('size')>0 || (window.location.href).indexOf('price')>0)
                window.location.href=window.location.href.replace('/c-sb.html','-'+pDeliDaysUrl+'/c-sb.html').replace('/-','/').replace('-/','/');
            else
                window.location.href=window.location.href.replace('/c-sb.html','/'+pDeliDaysUrl+'/c-sb.html').replace('/-','/').replace('-/','/');    
        }
        else if(window.location.href.indexOf('c-sb.html')==-1)
        {
            window.location.href='/'+$F('hdnPrdType').replace(' ','-')+'/'+pDeliDaysUrl+'/c-sb.html';
        }
    }
    catch(e)
    {
        alert('@ funDeliDaysUrl');
    }
}

function funPriceUrl(pPriceUrl)
{
    try
    {
        if(window.location.href.indexOf('c-sb.html')>1)
        {
            if(((window.location.href).indexOf('occasion')>0 || (window.location.href).indexOf('color')>0 || (window.location.href).indexOf('fabric')>0
                || (window.location.href).indexOf('style')>0 || (window.location.href).indexOf('art_style')>0 || (window.location.href).indexOf('celebrities')>0
                || (window.location.href).indexOf('films')>0 || (window.location.href).indexOf('size')>0) && (window.location.href).indexOf('delivery_days')==-1)
                window.location.href=window.location.href.replace('/c-sb.html','-'+pPriceUrl+'/c-sb.html').replace('/-','/').replace('-/','/');
            else if((window.location.href).indexOf('occasion')>0 || (window.location.href).indexOf('color')>0 || (window.location.href).indexOf('style')>0
                || (window.location.href).indexOf('style')>0 || (window.location.href).indexOf('art_style')>0 || (window.location.href).indexOf('celebrities')>0
                || (window.location.href).indexOf('films')>0 || (window.location.href).indexOf('size')>0 && (window.location.href).indexOf('delivery_days')>0)
               {
                    var vUrl=''
                    vUrl+=window.location.href.replace(window.location.href.slice(window.location.href.indexOf('delivery_days')-3,window.location.href.lastIndexOf('.html')+5),
                    pPriceUrl+'-'+window.location.href.slice(window.location.href.indexOf('delivery_days')-3,window.location.href.lastIndexOf('.html')+5));
                    window.location.href=vUrl.replace('/-','-').replace('-/','-');
               }
            else if((window.location.href).indexOf('delivery_days')>0)
                {
                    var vUrl=''
                    vUrl+=window.location.href.replace(window.location.href.slice(window.location.href.indexOf('delivery_days')-3,window.location.href.lastIndexOf('.html')+5),
                    pPriceUrl+'-'+window.location.href.slice(window.location.href.indexOf('delivery_days')-3,window.location.href.lastIndexOf('.html')+5));
                    window.location.href=vUrl.replace('/-','-').replace('-/','-');
               }   
            else
                window.location.href=window.location.href.replace('/c-sb.html','/'+pPriceUrl+'/c-sb.html').replace('/-','/').replace('-/','/');
        }
        else if(window.location.href.indexOf('c-sb.html')==-1)
        {
            window.location.href='/'+$F('hdnPrdType').replace(' ','-')+'/'+pPriceUrl+'/c-sb.html';
        }
    }
    catch(e)
    {
        alert('@ funPriceUrl');
    }
}

function funPrdsPageLoad()
{
    try
    {
         if((window.location.href).indexOf('size')>0 && $('CollapsiblePanelCustSize')!=null)
            $('CollapsiblePanelCustSize').style.display='none';
         if((window.location.href).indexOf('delivery_days')>0 && $('CollapsiblePanelDeliDays')!=null)
            $('CollapsiblePanelDeliDays').style.display='none';
         if((window.location.href).indexOf('-price-')>0 && $('CollapsiblePanelPrice')!=null)
            $('CollapsiblePanelPrice').style.display='none';
        if((window.location.href).indexOf('rmsize')>0 && $('CollapsiblePanelRMSize')!=null)
            $('CollapsiblePanelRMSize').style.display='none';
    }
    catch(e)
    {
        alert('@ funPrdsPageLoad');
    }
}

function funMultipleSearch()
{   
    var vPrdType='';
    var vColor='';    
    var vPriceRange='';       
    var vDeliDays='';
    vPrdType=$F('hdnPrdType');
    if($('ddPriceRange').options[$('ddPriceRange').selectedIndex].value=='-- Select Price Range --')
        vPriceRange='';
    else if($('ddPriceRange').options[$('ddPriceRange').selectedIndex].value!='-- Select Price Range --')
        vPriceRange=$('ddPriceRange').options[$('ddPriceRange').selectedIndex].value;
    if($('ddlDeliDays').options[$('ddlDeliDays').selectedIndex].value=='-- Select Delivery Days --')
        vDeliDays='';
    else if($('ddlDeliDays').options[$('ddlDeliDays').selectedIndex].value!='-- Select Delivery Days --')
        vDeliDays=$('ddlDeliDays').options[$('ddlDeliDays').selectedIndex].value;   
    if($F('ddColor')!='-- Select Color --')
    {
        vColor = $A($('ddColor').options).find(function(option) { return option.selected; } );
        vColor=(vColor.text).replace(/ /gi,'_').toLowerCase()+'-color-';
    }
    if(($F('ddColor')!='-- Select Color --') || (vPriceRange!='') || (vDeliDays!=''))
    {
        //1.occasion 2.color 3.style 4.fabric 5.size 6.price 7.delivery-days        
        var vPartialUrl=vColor+vPriceRange+vDeliDays;
        if((window.location.href).indexOf('EStoreUI') > -1)
        {                           
            window.location.href=('/EStoreUI/'+vPrdType+'/'+vPartialUrl+'/c-sb.html').replace('--','-').replace('-/','/').replace('/-','/').replace('//','/');
        }
        if((window.location.href).indexOf('EStoreUI')== -1)
            window.location.href=('/'+vPrdType+'/'+vPartialUrl+'/c-sb.html').replace('--','-').replace('-/','/').replace('/-','/').replace('//','/');
    }
    else if(($F('ddColor')=='-- Select Color --') && (vPriceRange=='') && (vDeliDays==''))
        alert('Select any of the above option...');}
  
  
function funMultipleGblSearch()
{   
    var vPrdType='';
    if($('ddlPrdType')!=null)
    {
        vPrdType=$('ddlPrdType').options[$('ddlPrdType').selectedIndex].value;
        if(vPrdType!='-- Select Product Type --')
            vPrdType=vPrdType;
    }    
    var vColor='';    
    var vPriceRange='';       
    var vDeliDays='';
    
    if($('ddPriceRange').options[$('ddPriceRange').selectedIndex].value=='-- Select Price Range --')
        vPriceRange='';
    else if($('ddPriceRange').options[$('ddPriceRange').selectedIndex].value!='-- Select Price Range --')
        vPriceRange=$('ddPriceRange').options[$('ddPriceRange').selectedIndex].value;
    if($('ddlDeliDays').options[$('ddlDeliDays').selectedIndex].value=='-- Select Delivery Days --')
        vDeliDays='';
    else if($('ddlDeliDays').options[$('ddlDeliDays').selectedIndex].value!='-- Select Delivery Days --')
        vDeliDays=$('ddlDeliDays').options[$('ddlDeliDays').selectedIndex].value;   
    if($F('ddColor')!='-- Select Color --')
    {
        vColor = $A($('ddColor').options).find(function(option) { return option.selected; } );
        vColor=(vColor.text).replace(/ /gi,'_').toLowerCase()+'-color-';
    }
    if(($F('ddColor')!='-- Select Color --' || (vPriceRange!='') || (vDeliDays!='')) && (vPrdType!='-- Select Product Type --'))
    {
        //1.occasion 2.color 3.style 4.fabric 5.size 6.price 7.delivery-days        
        var vPartialUrl=vColor+vPriceRange+vDeliDays;
        if((window.location.href).indexOf('EStoreUI') > -1)
        {                           
            window.location.href=('/EStoreUI/'+vPrdType+'/'+vPartialUrl+'/c-sb.html').replace('--','-').replace('-/','/').replace('/-','/').replace('//','/');
        }
        if((window.location.href).indexOf('EStoreUI')== -1)
            window.location.href=('/'+vPrdType+'/'+vPartialUrl+'/c-sb.html').replace('--','-').replace('-/','/').replace('/-','/').replace('//','/');
    }
    else if(($F('ddColor')=='-- Select Color --') && (vPriceRange=='') && (vDeliDays=='') &&  ( (vPrdType!='') && vPrdType=='-- Select Product Type --'))
        alert('Select any of the above option with product type...');
    else if(($F('ddColor')=='-- Select Color --' || (vPriceRange=='') || (vDeliDays=='')) &&  ( vPrdType!='-- Select Product Type --'))
        alert('Select any of the above option with product type...');}
        

function funCallForSortBy(pSortBy)
{
    try
    {
        new Ajax.Request('/GenetricHandler/SmartSearch.ashx?qStr=PrdsV2||SortBy|'+pSortBy+'|',
            {
                method: 'get',
                onSuccess: '',
                onFailure: ''
            });
    }
    catch(e)
    {
        alert('@ funCallForSortBy');
    }
}

function funCheckLoginV2(pMode,pUId)
{
    try
    {
        switch(pMode)
        {
            case 'B2BLogin':
                if($F('hdnBussType')=='B2B' && $F('hdnUsrId')=='0')
                {
                    $('dvb2blogin').style.display='block';     
                    $('dvb2blogin').style.visibility='visible';             
                }
                break;
            case 'ReturnsLogin':
                    if(pUId>0)
                    {
//                        qStr='PrdsV2||ReturnsLogedOn|'+pUId+'|';
//                        funCallHandlerLogOn(qStr);  
                        window.location.href='/returns-v2.aspx';
                        return true;
                    }
                    else
                    {
                        $('dvLoginParent').style.display='block';
                        $('dvLoginParent').style.visibility='visible';  
                        //$('dvLoginParent').style.backgroundImage='url(http://localhost:4717/EStoreUI/image/opacity.png)';  
                        $('dvLoginParent').style.zIndex='1000001';
                        $('dvLoginParent').style.minHeight='100%';
                        $('dvLoginParent').style.position='fixed';
                        $('dvLoginParent').style.width='100%';
                        $('dvLoginParent').style.left='25%';
                       // $('dvLoginParent').style.opacity='0.5px';
                    }
                break;
        }
    }
    catch(e)
    {
//        alert('@ funB2BLoginV2')
    }
}

function funChkLoginV2(pMode)
{
    try
    {
        var ErrMsg='',qStr='';              
        if($('txtLogin').value==''|| emailCheck($('txtLogin').value)==false || funValidateEmail($('txtLogin').value)==false)    
            ErrMsg='\n Login-ID Missing/Invalid';
        if($('txtPwd').value=='')
            ErrMsg=ErrMsg + '\n Password';    
        if(ErrMsg!='')
        {  
            alert('Please submit the below required details.\r\n-------------------------------------------------\r'+ErrMsg);                      
            return false;            
        }
        else
        {
            switch(pMode)
            {
                case 'B2BLogin':
                    qStr='PrdsV2||B2BLogin|'+$('txtLogin').value+'|'+$('txtPwd').value+'|||||';
                    funCallHandlerPrdsV2(qStr);  
                    break;
                case 'ReturnsLogin':
                    qStr='PrdsV2||ReturnsLogin|'+$('txtLogin').value+'|'+$('txtPwd').value+'|||||';
                    funCallHandlerLogOn(qStr);  
                    break;
            }
        }
    }
    catch(e)
    {
        alert('funChkB2BLoginV2');        
    }    
}

function funCallHandlerLogOn(qStr)
{    
    try
    {   
        new Ajax.Request($F('hdnAppPath')+'GenetricHandler/SmartSearch.ashx?qStr='+qStr,
            {
                method: 'get',
                onSuccess: funLogOnSuccess,
                onFailure: funLogOnFailure
            });
    }
    catch(e)
    {
        alert('@ funCallHandlerPrdsV2');
    }
}

function funLogOnSuccess(OrigionalRequest)
{
    try
    {
        var arrResult=new Array();        
        arrResult=OrigionalRequest.responseText.split('|');    
        if(arrResult.length>0)
        {
            switch(arrResult[0])
            {
                case 'ReturnsLogOn':
                    if(arrResult[1]=='N')
                        alert('You have no order to return to us');
                    else if(arrResult[1]=='Y')
                        window.location.href='/returns-v2.aspx';
                    break;
                 case 'ReturnsLogin':
                    if(arrResult[1]=='You have logged on')
                        window.location.href='/returns-v2.aspx';
                    else if(arrResult[1]!='You have logged on')
                        alert(arrResult[1]);
                    break;
            }
            return true;
        }
    }
    catch(e)
    {
        alert('@ funLogOnSuccess')
    }
}

function funLogOnFailure(OrigionalRequest)
{
    try
    {
        alert(OrigionalRequest.ResponseText)
    }
    catch(e)
    {
        alert('@ funLogOnSuccess')
    }
}


function funCallVisitedPrdHtry(qStr1,qStr2)
{   
    try
    {  
        qStr='PrdsV2||VisitedPrdHtry|'+qStr1+'|'+qStr2;
        new Ajax.Request($F('hdnAppPath')+'GenetricHandler/SmartSearch.ashx?qStr='+qStr,
            {
                method: 'get',
                onSuccess: funCallVisitedPrdHtrySuccess,
                onFailure: funCallVisitedPrdHtryFailure
            });
    }
    catch(e)
    {
        alert('@ funCallHandlerPrdsV2');
    }
}

function funCallVisitedPrdHtrySuccess(OrigionalRequest)
{
    try
    {
        var arrResult=new Array();        
        arrResult=OrigionalRequest.responseText.split('|');    
        if(arrResult.length>0)
        {
            switch(arrResult[0])
            {
                case "VisitedPrdHtry":
                if(arrResult[1]=='Y')
                    window.location.href=window.location.href;
            }
            return true;
        }
    }
    catch(e)
    {
        alert('@ funCallVisitedPrdHtrySuccess')
    }
}

function funCallVisitedPrdHtryFailure(OrigionalRequest)
{
    try
    {
        alert(OrigionalRequest.ResponseText)
    }
    catch(e)
    {
        alert('@ funCallVisitedPrdHtryFailure')
    }
}

$j(document).ready(function(){  
  /* Nav flyouts */
  $j('.menu ul li').hover(navHoverOver, navHoverOff);
  $j('.flyDown').each(function () {
  });
});

function navHoverOver(e) {
  $j(this).addClass('current1');
  $j(this).find('.flyDown').stop().fadeTo('fast', 1, function() {$j(this).show();});
}

function navHoverOff(e) {
  $j(this).removeClass('current1');
  $j(this).find('.flyDown').stop().fadeTo('fast', 0, function() {$j(this).hide();});
}


function funAnniversaryShow()
{
    $j('#overlay').fadeIn(1000);
    $('overlay').style.display='block';
    $('overlay').style.visibility='visible';              
    $('overlay').style.zIndex='1000001';            
    $('overlay').style.position='absolute';
    $('overlay').style.width='430px';
    $('overlay').style.border='1px solid #ccc';
    $('overlay').style.top='95px';
    $('overlay').style.left='19%';
}
function funLowPriceShow()
{
    $j('#LowPrice').fadeIn(1000);
    $('LowPrice').style.display='block';
    $('LowPrice').style.visibility='visible';              
    $('LowPrice').style.zIndex='1000001';            
    $('LowPrice').style.position='absolute';
    $('LowPrice').style.width='430px';
    $('LowPrice').style.border='1px solid #ccc';
    $('LowPrice').style.top='80px';
    $('LowPrice').style.left='35%';
}

funClrSearch1=function(){     
    if($F('txtPrdSer')=='Product Search')
         $('txtPrdSer').value='';
 } 
funChkPrdSearch1=function(){     
    if($F('txtPrdSer')==''||$F('txtPrdSer')=='Product Search' 
        ||funInvalidText($F('txtPrdSer'))==false)
    {
          alert('Search Keyword Missing / Invalid');
          return false;
    }
    else 
        return true;
 }
funGo1=function(){   
    if(funChkPrdSearch1()==true){           
        window.location.href=$F('hdnAppPath')+"search/" + $F('txtPrdSer').trim().replace(/ /gi,'-').toLowerCase()+".html";  
        }
} 

 $j(document).ready(
    function() {
            $j(".currency img.flag").addClass("flagvisibility");
            $j(".currency dt a").click(function() {$j(".currency dd ul").toggle(); });

            $j(".currency dd ul li a").click(function() {var text = $j(this).html();
            $j(".currency dt a span").html(text);$j(".currency dd ul").hide();});

            $j(document).bind('click', function(e) {var $jclicked = $j(e.target);
                    if (! $jclicked.parents().hasClass("currency"))
                        $j(".currency dd ul").hide();
            });
        });
        
function funManageSubs()
    {
        try
        {
            $('dvManageSubs').style.display='block';
            new Ajax.Request('/GenetricHandler/SmartSearch.ashx?qStr=PrdsV2||ManageSubs|',
                {
                    method:'get',
                    onSuccess: funManageSubsSuccess,
                    onFailure: funManageSubsFailure
                }
            );
        }
        catch(e)
        {
            alert('@ funManageSubs');
        }
    }
    function funManageSubsSuccess(OriginalRequest)
    {
        try
        {
            var arrResult=new Array();
            arrResult=OriginalRequest.responseText.split('|');
            if (arrResult[0]=='Y')
            {
                document.getElementById("rbMailerY").checked=true;
                document.getElementById("rbMailerN").checked=false;
            }
            else 
            {
                document.getElementById("rbMailerN").checked=true;
                document.getElementById("rbMailerY").checked=false;
            }
            if (arrResult[1]=='Y')
            {
                document.getElementById("rbSMSY").checked=true;
                document.getElementById("rbSMSN").checked=false;
            }
            else 
            {
                document.getElementById("rbSMSN").checked=true;
                document.getElementById("rbSMSY").checked=false;
            }                
            
        }
        catch(e)
        {
            alert('@ funManageSubsSuccess');
        }
    }
    function funManageSubsFailure(OriginalRequest)
    {
        try
        {
                       
        }
        catch(e)
        {
            alert('@ funManageSubsSuccess');
        }
    }
    
   function funLazyLoad()
   {
        $j(".jquery-lazyload").lazyload({ 
			placeholder : "http://www.cbazaar.com/image/lazyloading.gif",
			effect : "fadeIn"
		});		
   }
   
/* Facebook login code start - 05 december 2011  


//    if((window.location.href).indexOf('www.cbazaar.in')>-1)
//        setInterval("getCookie()",1000);                                    
    function getCookie()
    {  
        var vFBCookie=document.cookie.split(";");
        var c_name, c_value;
        var vFBAuthId, vUserId;
        var vDomain='';                                        
        if(window.sessionStorage == undefined || window.sessionStorage.getItem('sesIsCookieExists') != 'Y')
        {
            for (i=0;i<vFBCookie.length;i++)
            {
                if(vFBCookie[i].indexOf("fbs_")>0)
                {                                                    
                    sessionStorage.setItem('sesIsCookieExists',"Y");
                    c_name=vFBCookie[i].substr(0,vFBCookie[i].indexOf("="));
                    c_value=vFBCookie[i].substr(vFBCookie[i].indexOf("=")+1);
                    vFBCookie=c_value.split("&");
                    for (i=0;i<vFBCookie.length;i++)
                    {
                        if(vFBCookie[i].indexOf("access_token")>0)
                            vFBAuthId=vFBCookie[i].substr(vFBCookie[i].indexOf("=")+1);
                        if(vFBCookie[i].substr(0,vFBCookie[i].indexOf("="))=="uid")
                        {
                            vUserId=vFBCookie[i].substr(vFBCookie[i].indexOf("=")+1);  
                            vUserId=vUserId.substr(0,vUserId.length-1);
                        }
                    }                                                
                    $j.getJSON("https://graph.facebook.com/"+vUserId+'?access_token='+vFBAuthId,
                    function(data){                                                                                                                   
                    if((window.location.href).indexOf('EStoreUI')>-1)
                        vDomain='/EStoreUI';
                    new Ajax.Request(vDomain+'/GenetricHandler/SmartSearch.ashx?qStr=PrdsV2|fb|facebook|'+data.email+'|'+data.first_name+'|'+data.last_name+'|'+data.gender,
                    {
                        method: 'get',
                        onSuccess: funFBSuccess,
                        onFailure: funFBFailure
                    });
                    
                    });  
                }                                                
            }
        }
    }
    function funFBSuccess(OrigionalRequest)
    {
        try
        {
            var vResponse=OrigionalRequest.responseText;
            var arrResult=new Array();        
            arrResult=OrigionalRequest.responseText.split('|');        
            if(arrResult.length>0)
            {
                if(arrResult[0]=='B2C')
                {
                    if(arrResult[1]=='Y')
                    {
                        alert('Hi, '+arrResult[2]);
                        window.location.href='/default.aspx';
                        return true;
                    }
                    else  if(arrResult[1]=='N')
                    {
                        alert('Hi, '+arrResult[2]);
                        return true;
                    }
                }
            }
        }
        catch(e)
        {
            //alert('hi');
        }
    }
    function funFBFailure(OrigionalRequest)
    {
        alert('failed @ funFBFailure');
    }
   

/* Facebook login code end */
