  /*******/

  var IE4 = document.all;
  var NS6 = document.getElementById && !document.all;
  var disappearDelay = 500; // miliseconds  
  var http = window.location.protocol;
  var port = window.location.host;
  var hostname='localhost';
  var applicationname="seller";
  var ajaxfolder="Ajaxs";
  //var hostname='stagingpricesbolo';
  var urlpath = http +'//'+ hostname+'/'+applicationname; //Local
  //var urlpath = http +'//'+port+'/'; //Live
  var apppath = urlpath +'/'+ applicationname;
  var ajaxpath = apppath +'/'+ ajaxfolder;
   
function getposOffset(what, offsettype){
  var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
  var parentEl=what.offsetParent;
  while (parentEl!=null){
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
    parentEl=parentEl.offsetParent;
  }
  return totaloffset;
}

function ToggleMenuOnOff (menuName) {
    var menu = document.getElementById(menuName);
    if (menu.style.display == 'none') {
      menu.style.display = 'block';
    } else {
      menu.style.display = 'none';
    }
}
function ToggleClassOnOff (menuName) 
{
 if(document.getElementById(menuName).className.length>0)
    { 
        document.getElementById(menuName).className="";
    }
   else
   {
        document.getElementById(menuName).className="on";    
   }
    //alert('class off');
    //enablePage();
}
//function enablePage()
//{
//    document.oncontextmenu=enable;
//    document.onclick = enable;
//    document.onkeypress = enable;
//}
//function enable() 
//{
//    return true;
//}

function ToggleMenuClassOnOff(classid,menuid)
{
  ToggleMenuOnOff(menuid);
  ToggleClassOnOff(classid);
}

function ClearMessage(control)
{   
     document.getElementById(control).innerHTML = "";  
}

function pageoptiontoggle(val)
 {   
   ToggleMenuOnOff(val);
   var s =getCookie('pricebolo-cur-style');  
   if(s.length>0)
     document.getElementById(s).className="on";
   else
    document.getElementById('sy1').className="on";
 }

function OpenWindow (target) { 
  window.open(target, "_Child", "toolbar=no,scrollbars=yes,resizable=yes,width=400,height=400"); 
}

function OpenPostWindow (target) { 
  window.open(target, "_Child", "resizable=yes,width=500,height=700"); 
}

function getCookie(sName) {
	var cookie = "" + document.cookie;
	var start = cookie.indexOf(sName);
	if (cookie == "" || start == -1) 
		return "";
	var end = cookie.indexOf(';',start);
	if (end == -1)
		end = cookie.length;
	return unescape(cookie.substring(start+sName.length + 1,end));
}
function setCookie(sName, value) {
	document.cookie = sName + "=" + escape(value) + ";path=/;";
}
function setCookieForever(sName, value) {
	document.cookie = sName + "=" + escape(value) + ";path=/;expires=Fri, 1 Jan 2010 00:00:00 GMT;";
}

//This getUrlVars function is used to get the QueryString Value
function getUrlVars()
{
//alert("");
  var vars = [], hash;
  var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
  for(var i = 0; i < hashes.length; i++)
    { 
      hash = hashes[i].split('=');
      vars.push(hash[0]); 
      vars[hash[0]] = hash[1];
     } 
    return vars;
}

// Popups SendToFriend window
function SendToFriendPopup(pURL,pItemTitle,pItemPrice,pCateName)
{ 
    if (pURL.length == 0)
        pURL = window.location.href;    
    var url = urlpath +'/User/SendToFriend.aspx' + '?URL=' + pURL +'&ItemTittle='+pItemTitle+'&ItemPrice='+pItemPrice+'&CategoryName='+pCateName+'&loctype=RF';     
   	SendToFriendwindow=dhtmlmodal.open('Login', 'iframe',url, '..::Pricesbolo::.. ', 'width=560px,height=305px,center=1,resize=0,scrolling=0');
   	SendToFriendwindow.onclose=function(){ 
        return true;
    }
} 
function SendToFriendPopupClose(pValue)
{
   parent.SendToFriendwindow.hide(); 
   window.location = parent.location = pValue;
}
function SendToFriendPageClosed()
{  
    parent.SendToFriendwindow.hide();
    var path = window.parent.location.href;
    window.parent.location =path;
}

// popup SendToFriend script ends
// pricealertLoginpopup
function PriceAlertLoginpopup()
{         
    var url = urlpath +'/User/PopupLogin.aspx?type=palert';     
   	Loginwindow=dhtmlmodal.open('Login', 'iframe',url, '..::Pricesbolo::.. ', 'width=450px,height=320px,center=1,resize=0,scrolling=0');
    Loginwindow.onclose=function(){ 
        return true;
    }
} 
// Loginpopup Script
function Loginpopup()
{           
    var url = urlpath +'/User/LoginPopup.aspx';     
   	Loginwindow=dhtmlmodal.open('Login', 'iframe',url, 'Login ', 'width=330px,height=215px,center=1,resize=0,scrolling=0');
    Loginwindow.onclose=function(){ 
        return true;
    }
} 
function LogoUpload()
{           
    var url = urlpath +'/WebUI/SellerImageUpload.aspx';    
   	Loginwindow=dhtmlmodal.open('Login', 'iframe',url, 'Logo Upload', 'width=330px,height=250px,center=1,resize=0,scrolling=0');
    Loginwindow.onclose=function(){ 
        return true;
    }
}
function CouponImageUpload(pExistImg)
{           
    var url = urlpath +'/WebUI/CouponImageUpload.aspx?couponimg='+pExistImg;     
   	Loginwindow=dhtmlmodal.open('Login', 'iframe',url, 'Logo Upload', 'width=500px,height=500px,center=1,resize=0,scrolling=0');
    Loginwindow.onclose=function(){ 
        return true;
    }
}

function Loginpopupclose(pValue)
{
   parent.Loginwindow.hide();           
   window.location = parent.location = pValue;   
}
function LoginPageClosed()
{  
    parent.Loginwindow.hide();
    var path = window.parent.location.href;   
    window.parent.location =path;     
}

//End "Loginpopup" function
//Send SMS to Friend Starts here
function SendSMSToFriendPopup(pMessage)
{   // alert(pItem+": "+pDesc);    
          
    var url = urlpath +'/User/PopupSendSMSFriend.aspx?desc='+pMessage;     
   	Loginwindow=dhtmlmodal.open('Login', 'iframe',url, 'Share this listing via SMS', 'width=420px,height=230px,center=1,resize=0,scrolling=0');
    Loginwindow.onclose=function(){ 
        return true;
    }
} 

//Send SMS to Friend Ends here

//Send SMS to Seller Starts here
function SendSMSToSellerPopup(pMblno,pItemTitle)
{   
    var qryValue=pMblno+":"+pItemTitle;   
         
    var url = urlpath +'/User/PopupSendSMSSeller.aspx?cellno='+qryValue;     
   	Loginwindow=dhtmlmodal.open('Login', 'iframe',url, 'Contact seller via SMS', 'width=420px,height=250px,center=1,resize=0,scrolling=0');
    Loginwindow.onclose=function(){ 
        return true;
    }
} 
//Send Price Alert starts here

//Send SMS to Seller Starts here
function PriceAlertPopup(pType,pItemId,pTitle,pPriceRange,pClntEvent)
{   
    var qryValue='type='+pType+'&itemid='+pItemId+'&Title='+pTitle+'&Rate='+pPriceRange+'&clntevent='+pClntEvent;
   // alert(qryValue);   
    var url = urlpath +'/User/PriceAlert.aspx?'+qryValue;
    if(pType =="NPA")
    {
        url = urlpath +'/User/OpeningPriceAlert.aspx?'+qryValue;
   	    Loginwindow=dhtmlmodal.open('Login', 'iframe',url, 'Opening Price Alert', 'width=480px,height=320px,center=1,resize=0,scrolling=0');
   	}
   	else
   	   Loginwindow=dhtmlmodal.open('Login', 'iframe',url, 'Price Alert', 'width=480px,height=320px,center=1,resize=0,scrolling=0');
    Loginwindow.onclose=function(){ 
        return true;
    }
} 
//Send Price Alert Ends here

// Start Window Disable
function toggleDisableWindow(el) {
    //el = document.getElementById(el);
    try {
        el.disabled = el.disabled ? false : true;
		el.style.backgroundColor = el.style.backgroundColor == "gray" ? "" : "gray";					
    }
    catch(E){}
    try {
    if (el.childNodes && el.childNodes.length > 0) {
        for (var x = 0; x < el.childNodes.length; x++) {
             toggleDisableWindow(el.childNodes[x]);
        }
     }
    } catch(err){}
}
// End Window Disable
//ExpandCollapse Script Start
function PanelExpandCollapse(DivId,ImgId1,ImgId2)
        {                  
           if(document.getElementById(DivId).style.display == "" )
           {                              
            document.getElementById(DivId).style.display = "none";           
            document.getElementById(ImgId1).style.display = "none";
            document.getElementById(ImgId2).style.display = "";
           }
           else
           {                   
            document.getElementById(DivId).style.display = "";
            document.getElementById(ImgId2).style.display = "none";
            document.getElementById(ImgId1).style.display = "";
           }    
        }
 //ExpandCollapse Script End
 
 
/********************************************************
Author : Karthik.P
Description : Removes leading and trailing blank spaces
Returns : modified string
*********************************************************/
function Trim(str)
{
	str = str.replace(/^\s+/, ""); // beginning spaces are convert to an empty string
	str = str.replace(/\s+$/, ""); // ending spaces are convert to an empty string
	return(str);
}


/********************************************************
Author : Karthik.P
Description : This fn. check each word in the given string and splits the string 
as per the pWordSize given. If pWordSize is 0 then by default is 20.
Returns : modified string
*********************************************************/
function WordSlice(pString,pWordSize)
{
    var sRetVal = pString;
    var iSize = 20;    
    if (pWordSize > 0)
        iSize = pWordSize;    
    if (pString.length > 0)
    {
        var arr = pString.split(' ');        
        for (i=0;i<arr.length;i++)
            if (arr[i].length > iSize)
            {
                //check splice method for more details
                arr.splice(i+1,0,arr[i].substr(iSize,arr[i].length)); 
                arr[i] = arr[i].substr(0,iSize);
            }
        sRetVal = arr.join(' ');
    }    
    return sRetVal;
}

/********************************************************
Author : Karthik.P
Description : Function to get Spam Verification Code
*********************************************************/
var _spamcode;
function GenerateSpamCode(pObjID)
{ 
  var code='';
  for(k=0;k<=4;k++)
  {
     var charval = 33 + Math.round(Math.random() * 52);
     if (charval >= 65 && charval <= 90)
        code += String.fromCharCode(charval);        
     else
        code += (charval + '').substring(1);       
  }
  _spamcode = code;
  document.getElementById(pObjID).innerHTML=code;
  return code;
}


function getUniqueId()
{ 
  var code='';
  for(k=0;k<=4;k++)
  {
     var charval = 33 + Math.round(Math.random() * 52);
     if (charval >= 65 && charval <= 90)
        code += String.fromCharCode(charval);        
     else
        code += (charval + '').substring(1);       
  } 
  return code;
}

function GetSpamCode()
{    
    return _spamcode;
}

function curpageredirect()
{
   var pghref = Trim(window.location.href);  
    try
    {   } catch(e){}
                               
     window.location=pghref; 
  
}

function OnFreeTextKeyEnter(pevent,btnSearch,txtSearch,pUrl)
{ 
    if (pevent.which != null && pevent.which == 13)
    {   
         pevent.returnValue=false;
         pevent.cancelBubble=true;
         FreeTextSearch(btnSearch,txtSearch,pUrl);      
    }
    else if (pevent.keyCode == 13)
    {
     pevent.returnValue=false;
     pevent.cancelBubble=true;
     FreeTextSearch(btnSearch,txtSearch,pUrl);    
    }
} 
 
function  FreeTextSearch(btnSearch,txtSearch,pUrl)
{ 
  var btn=document.getElementById(btnSearch);
  var searchText=document.getElementById(txtSearch).value;
  if(searchText.length > 0 && searchText != "Quick Search")
  {
      var url= pUrl +"?ST="+searchText;  
      window.location= url;
  }
  else
    alert("Enter valid search text");
}

function OpenPrintPopUP()
{  
    var url = urlpath +'/Coupons/ConfirmCoupon.aspx';  
   	Loginwindow	= dhtmlmodal.open('Login', 'iframe',url, '..::Pricesbolo::.. ', 'width=750px,height=500px,center=1,resize=0,scrolling=0');   	
    Loginwindow.onclose=function(){ 
        return true;
    }
}
//this function used in RecentlyvieweditemImgae control 

try{
stepcarousel.setup({
	galleryid: 'hotproductgallery', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
})}catch(e){}
