﻿var TO;

function ClearEmptyTD()
{
    oTD = document.getElementsByTagName("TD");
 
    
   
    for( i=0; i < oTD.length; i++)
    {
         if (( oTD[i].innerHTML == ' ' ) ||  ( oTD[i].innerHTML == '' ) )
         {  
            oTD[i].style.border = "1px solid white";
            oTD[i].style.display="none";     
         }         
    }
    
}
function MagnifyingHistoryImg( inImageUrl  , UseFrame , popUpDivId, galleryPath)
{
   if(UseFrame == "True")
   {
        newDiv = document.getElementById(popUpDivId);
        newDiv.innerHTML = "<div class=\"imgMovieDivSize\"><iframe src=\"" + inImageUrl + "\" ALLOWTRANSPARENCY=\"true\" WIDTH=\"341\" HEIGHT=\"305\" FRAMEBORDER=\"0\">&#160;</iframe></div><div onclick=removeMagnifyingHistoryImg(\""+popUpDivId+"\");  class=\"closeButtonFrame\"><img src=\"../../../Images/close_icon.gif\"></div>" ;
        newDiv.style.display = "block";
   }
   else
   {
            newDiv = document.getElementById(popUpDivId);
            newDiv.innerHTML = "<div class=\"imgMovieDivSize\"><img  src=" + inImageUrl + "/></div><div onclick=removeMagnifyingHistoryImg(\""+popUpDivId+"\");  class=\"closeButtonFrame\"><img src=\"" + galleryPath + "close_icon.gif\"></div>" ;
            newDiv.style.display = "block";
   }
}




function MagnifyingResponseHistoryImg (inImageUrl  , UseFrame , popUpDivId , galleryPath)
{
   if(UseFrame == "True")
   {
        newDiv = document.getElementById(popUpDivId);
        newDiv.innerHTML = "<div class=\"imgMovieDivSize\"><iframe src=\"" + inImageUrl + "\" ALLOWTRANSPARENCY=\"true\" WIDTH=\"341\" HEIGHT=\"305\" FRAMEBORDER=\"0\">&#160;</iframe></div><div onclick=removeMagnifyingHistoryImg(\""+popUpDivId+"\");  class=\"closeButtonFrameRes\"><img src=\"" + galleryPath + "close_icon.gif\"></div>" ;
        newDiv.style.display = "block";
   }
   else
   {
            newDiv = document.getElementById(popUpDivId);
            newDiv.innerHTML = "<div class=\"imgMovieDivSize\"><img  src=" + inImageUrl + "/></div><div onclick=removeMagnifyingHistoryImg(\""+popUpDivId+"\");  class=\"closeButtonFrameRes\"><img src=\"" + galleryPath + "close_icon.gif\"></div>" ;
            newDiv.style.display = "block";
   }
}


function removeMagnifyingHistoryImg(div) 
{
  var d = document.getElementById(div);
  d.style.display = "none";
}

function CheckThankYouView()
{
    var ThankYouID =  document.getElementById("ctl00$MainContent$ThankYouID");
    var MainFormID =  document.getElementById("ctl00$MainContent$MainFormID");
    
    
    alert( ThankYouID );
    alert( MainFormID );
    
    
}



function ValidateContect()
{

    var bValid = true;
    var ERR_STRING_TO_LONG =  document.getElementById("ctl00_MainContent_ERR_STRING_TO_LONG");
    var ERR_FILE_TO_BIG =  document.getElementById("ctl00_MainContent_ERR_FILE_TO_BIG");
    var ERR_WRONG_INPUT =  document.getElementById("ctl00_MainContent_ERR_WRONG_INPUT");
    var ERR_NOT_VALID_EMAIL =  document.getElementById("ctl00_MainContent_ERR_NOT_VALID_EMAIL");
    var oDivErrMsg =  document.getElementById("ctl00_MainContent_DivErrMsg");
    
    
    var InputNameID =  document.getElementById("ctl00_MainContent_InputNameID");
    var InputSurNameID =  document.getElementById("ctl00_MainContent_InputSurNameID");
    var InputRegionID =  document.getElementById("ctl00_MainContent_InputRegionID");
    var InputEmailID =  document.getElementById("ctl00_MainContent_InputEmailID");
    var FileUpload1 =  document.getElementById("ctl00_MainContent_UploadFile");
    var InputContectID =  document.getElementById("ctl00_MainContent_InputContectID");
    var lblErr =  document.getElementById("ctl00_MainContent_lblErr");
    var re = new  RegExp("<(.|\n)*?>" );;
    
    
    InputNameID.style.border =  "1px solid Gray";
    InputSurNameID.style.border =  "1px solid Gray";
    InputRegionID.style.border = "1px solid Gray";
    InputEmailID.style.border =  "1px solid Gray";
    FileUpload1.style.border = "1px solid Gray";
    InputContectID.style.border =  "1px solid Gray";  

    lblErr.value="" ;
    
    /*INput SurName*/
    if (InputSurNameID.value.length > 40 )
    {
        lblErr.innerHTML = ERR_STRING_TO_LONG.value;
        InputSurNameID.style.border = "1px solid red";
        oDivErrMsg.className = "inputNamePos";
        return false;
    }  
   
    if ( re.exec(InputSurNameID.value) != null || InputSurNameID.value.length == 0 )
    {
        lblErr.innerHTML = ERR_WRONG_INPUT.value;
        InputSurNameID.style.border = "1px solid red";
        oDivErrMsg.className = "inputNamePos";
        return false;
    }
    
   /*Input Region*/
    if ( InputRegionID.value.length > 255 )
    {
        lblErr.innerHTML = ERR_STRING_TO_LONG.value;
        InputRegionID.style.border = "1px solid red";
        oDivErrMsg.className = "inputRegionPos";
        return false;
    }
    if ( re.exec(InputRegionID.value) != null || InputRegionID.value.length == 0)
    {
        lblErr.innerHTML = ERR_WRONG_INPUT.value;
        InputRegionID.style.border = "1px solid red";
        oDivErrMsg.className = "inputRegionPos";
        return false;
    }

   /*Input Email*/       
    if ( (InputEmailID.value.indexOf(".") < 2) && (InputEmailID.value.indexOf("@") < 0) )
    {  
        lblErr.innerHTML    = ERR_NOT_VALID_EMAIL.value;
        InputEmailID.style.border = "1px solid red";
        oDivErrMsg.className = "inputEmailPos";
        return false;
    }
    if ( re.exec(InputEmailID.value) != null || InputEmailID.value.length == 0)
    {
        lblErr.innerHTML = ERR_WRONG_INPUT.value;
        InputEmailID.style.border = "1px solid red";
        oDivErrMsg.className = "inputEmailPos";    
        return false;
    }
   
     /*Input content*/  
    if ( InputContectID.value.length > 3000 )
    {
        oDivErrMsg.innerHTML = ERR_STRING_TO_LONG.value;
        InputContectID.style.border = "1px solid red";
        oDivErrMsg.className = "inputContentPos";
        return false;
    }
    if ( re.exec(InputContectID.value) != null || InputContectID.value.length == 0 )
    {
        lblErr.innerHTML = ERR_WRONG_INPUT.value;
        InputContectID.style.border = "1px solid red";
        oDivErrMsg.className = "inputContentPos";
        return false;
    }
    return bValid;
}

function FAQsubmit()
{
    var disclamer = document.getElementById("disclamerInput");
    var result;
    if(disclamer.checked == true)
    {
        document.getElementById("ctl00_MainContent_UCdisclamer1_disError").style.display = "none";
        //document.forms[0].submit();
        result = true;
    }
    else
    {
        document.getElementById("ctl00_MainContent_UCdisclamer1_disError").style.display = "block";
        result = false;
    }
    return result;
}

function DoContectSubmit()
{
   
    var oDoSubmit = document.getElementById("ctl00_MainContent_DoSubmit");
    var oThankYou =  document.getElementById("ctl00_MainContent_ThankYouID");
    var FillFormText =  document.getElementById("ctl00_MainContent_FillFormTextID");
    var disclamer = document.getElementById("disclamerInput");
        
     
    if ( ValidateContect() )
    {
        if(disclamer.checked == true)
        {
            document.getElementById("ctl00_MainContent_UCdisclamer1_disError").style.display = "none";
            if ( FillFormText != null )
            {
                FillFormText.className  = "HideFillFormText";         
            }

            if ( oThankYou )
            {
                oThankYou.className  = "ShowThankyou";      
            }
        
            if ( oDoSubmit != null )
            {
                oDoSubmit.value = 'true';    
            }
                
            if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) 
            {
                theform = document.forms["aspnetForm"]; 
            }
            else 
            { 
                theform = document.aspnetform ; 
            }        
          
        }
        else
        {
            document.getElementById("ctl00_MainContent_UCdisclamer1_disError").style.display = "block";
           
        }
        
    }
    
}



function validatePositionApplication ()
{
    if(checkApplicationInputs())
    {
        var disclamer = document.getElementById("disclamerInput");
        var ok = true;
        if(disclamer.checked == true)
        {
            var oName = document.getElementById('ctl00_MainContent_ApplicantNameTxtBox');
            if (oName.value == ''){
                oName.style.borderColor = "red";
                oName.style.backgroundColor = "yellow";
                ok = false;
            }
            else{
               oName.style.borderColor = "gray";
               oName.style.backgroundColor = "#ffffff";
            }
            
            var oEmail = document.getElementById('ctl00_MainContent_ApplicantEmailTxtBox');
            if (oEmail.value == '' || !checkEmail(oEmail.value)){
                oEmail.style.borderColor = "red";
                oEmail.style.backgroundColor = "yellow";
                ok = false;
            }
            else{
                oEmail.style.borderColor = "gray";
                oEmail.style.backgroundColor = "#ffffff";
                
            }
            
            var oPhone = document.getElementById('ctl00_MainContent_ApplicantPhoneTxtBox');
            if (!checkPhone(oPhone.value)){
                oPhone.style.borderColor = "red";
                oPhone.style.backgroundColor = "yellow";
                ok = false;
            }
            else{
                oPhone.style.borderColor = "gray";
                oPhone.style.backgroundColor = "#ffffff";
                
            }
            if (!ok)
                return;
            document.getElementById("ctl00_MainContent_UCdisclamer1_disError").style.display = "none";
            document.forms[0].submit();
        }
        else
        {
            document.getElementById("ctl00_MainContent_UCdisclamer1_disError").style.display = "block";
        }
        //document.forms[0].submit();
    }
}

function checkEmail(inputvalue){	
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue)){         
		return true;   
    }else{   
		return false; 
    }
}

function checkPhone(str) 
{

    var phone2 =/^[0-9]{2,3}-? ?[0-9]{7}$/;

	if (str.match(phone2)) {
   		return true;
 	} else {
 	    if (str == '')
 	        return true;
 	    else
 		    return false;
 	}
}


function checkApplicationInputs()
{
    var textAreaContent = document.getElementById("ctl00_MainContent_aboutYourSelf");
    var resumeFile = document.getElementById("ctl00_MainContent_fileUploadID");
    var extension = "";
    
    if(textAreaContent.innerText.length > 1000)
    {
        document.getElementById("ctl00_MainContent_textAreaErr").style.display = "block";
        return false;
    }
    else
    {
        document.getElementById("ctl00_MainContent_textAreaErr").style.display = "none";
    }

    extension = resumeFile.value.substring(resumeFile.value.lastIndexOf("."))
    
    if (extension != ".doc" && extension != ".docx" && extension != ".txt" && extension != ".pdf" && extension != ".rtf" && resumeFile.value != " ")
    {
        document.getElementById("ctl00_MainContent_resumeFileErr").style.display = "block";
        return false;
    }
    else
    {
        document.getElementById("ctl00_MainContent_resumeFileErr").style.display = "none";
    }
    
    return true;
}

function OpenContectForm(SelectItemId)
{
    //MainFormID
    
    var oMainForm =  document.getElementById("ctl00_MainContent_MainFormID");
    var oSelectForm =  document.getElementById("SelectFormID");
    var oSelectedOption = document.getElementById("ctl00_MainContent_SelectedOption");
    var oDoSubmit = document.getElementById("ctl00_MainContent_DoSubmit");
    var oThankYou =  document.getElementById("ctl00_MainContent_newThank");
    var FillFormText =  document.getElementById("ctl00_MainContent_FillFormTextID");
    if(oSelectForm.value == ConsumerServicePageId)
    {
        window.location=ConsumerServiceUrl;
        return;
    }
    
    if ( FillFormText != null )
    {
        FillFormText.className  = "ShowFillFormText";         
    }
   
    if ( oThankYou != null  )
    {
        oThankYou.className  = "HideThankYou";         
    }
   
    //
    if ( oDoSubmit != null )
    {
        oDoSubmit.value = '';
    }
    
    
    if ( oMainForm != null )
    {        
        oMainForm.className  = "ShowForm";
    }
    
    if ( oSelectedOption != null )
    {
        oSelectedOption.value = oSelectForm.value;
    }
    
    /*Set the select box with the selected form name */
    var selectItem = document.getElementById("SelectFormID");
    for ( var i = 0; i < selectItem.options.length; i++ ) {
        if ( selectItem.options[i].value == SelectItemId ) {
            selectItem.options[i].selected = true;
            return;
        }
    }
   
}

function CheckHistoryForm ()
{
    
    var SubmitID =  document.getElementById("ctl00_MainContent_HistoryUpload1_HiddenSubmit");
    
    var theform; 
  
    
    var disclamer = document.getElementById("disclamerInput");
    
        if ( ValidateHistory() )
        {
             if(disclamer.checked == true)
             {
                document.getElementById("ctl00_MainContent_HistoryUpload1_ctl00_disError").style.display = "none";
                SubmitID.value = "true";
                if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) 
                {
                    theform = document.forms["aspnetForm"]; 
                    
                      
                }
                else 
                { 
                    theform = document.aspnetForm ; 
                    
                }      
         
                //theform.submit(); 
                document.forms[1].submit(); 
            }
            else
            {
                document.getElementById("ctl00_MainContent_HistoryUpload1_ctl00_disError").style.display = "block";
            }
        }
}

function ValidateHistory()
{
    var bValid = true;
        
    var MsgName =  document.getElementById("ctl00_MainContent_HistoryUpload1_" + "txtName");
    var MsgSurName =  document.getElementById("ctl00_MainContent_HistoryUpload1_" + "txtSurName");
    var MsgLocation =  document.getElementById("ctl00_MainContent_HistoryUpload1_" + "lblLocation");
    var MsgUpload =  document.getElementById("ctl00_MainContent_HistoryUpload1_" +"File1");
    var MsgStory =  document.getElementById("ctl00_MainContent_HistoryUpload1_" + "TAMyStory");
    var MsgTitle =  document.getElementById("ctl00_MainContent_HistoryUpload1_" + "UploadTitle");
    var MsgEmail =  document.getElementById("ctl00_MainContent_HistoryUpload1_" + "txtEmail");
    
    var ERR_STRING_TO_LONG =  document.getElementById("ctl00_MainContent_HistoryUpload1_" +"ERR_STRING_TO_LONG");
    var ERR_FILE_TO_BIG =  document.getElementById("ctl00_MainContent_HistoryUpload1_" +"ERR_FILE_TO_BIG");
    var ERR_WRONG_INPUT =  document.getElementById("ctl00_MainContent_HistoryUpload1_" +"ERR_WRONG_INPUT");
    var ERR_NOT_VALID_EMAIL =  document.getElementById("ctl00_MainContent_HistoryUpload1_" +"ERR_NOT_VALID_EMAIL");
    
    var DivErrMsgName =  document.getElementById("DivErrtxtName");
    
    var DivErrMsgEmail =  document.getElementById("DivErrtxtEmail");
    
    var DivErrMsgSurName =  document.getElementById("DivErrtxtSurName");
    var DivErrMsgLocation =  document.getElementById("DivErrlblLocation");
    var DivErrMsgUpload =  document.getElementById("DivErrFile1");
    var DivErrMsgStory =  document.getElementById("DivErrTAMyStory");
    var DivErrTitle = document.getElementById("DivErrUploadTitle");
    
    var re = new RegExp("<(.|\n)*?>" );
  
  /*Clear Error Divs value*/
    DivErrMsgName.innerHTML = ""; 
    DivErrMsgSurName.innerHTML = ""; 
    DivErrMsgLocation.innerHTML = ""; 
    DivErrMsgUpload.innerHTML = ""; 
    DivErrMsgStory.innerHTML = ""; 
    DivErrMsgName.innerHTML = ""; 
    DivErrMsgLocation.innerHTML = ""; 
    DivErrMsgStory.innerHTML = "";
    DivErrTitle.innerHTML = "";
    DivErrMsgName.innerHTML = "";
    DivErrMsgEmail.innerHTML = "";
    
    MsgName.style.border =  "1px solid Gray";
    MsgSurName.style.border =  "1px solid Gray";
    MsgLocation.style.border = "1px solid Gray";
    MsgUpload.style.border =  "1px solid Gray";
    MsgStory.style.border = "1px solid Gray";
    MsgTitle.style.border =  "1px solid Gray";  
    MsgEmail.style.border =  "1px solid Gray"; 
    
    if ( re.exec(MsgName.value) != null )
    {
        DivErrMsgName.innerHTML = ERR_WRONG_INPUT.value;
        MsgName.style.border = "1px solid red"
        return false;
    }
    
     if ( re.exec(MsgSurName.value) != null )
    {
        DivErrMsgSurName.innerHTML = ERR_WRONG_INPUT.value;
        MsgSurName.style.border = "1px solid red"
        return false;
    }
    
     if ( re.exec(MsgEmail.value) != null )
    {
        DivErrMsgEmail.innerHTML = ERR_WRONG_INPUT.value;
        MsgEmail.style.border = "1px solid red"
        return false;
    }
    
    if ( re.exec(MsgLocation.value) != null )
    {
        DivErrMsgLocation.innerHTML = ERR_WRONG_INPUT.value;
        MsgLocation.style.border = "1px solid red"
        return false;
    }
    
    if ( re.exec(MsgUpload.value) != null )
    {
        DivErrMsgUpload.innerHTML = ERR_WRONG_INPUT.value;
        MsgUpload.style.border = "1px solid red"
        return false;
    }
    
    if ( re.exec(MsgTitle.value) != null )
    {
        DivErrTitle.innerHTML = ERR_WRONG_INPUT.value;
        MsgTitle.style.border = "1px solid red"
        return false;
    }
    
    if ( re.exec(MsgStory.value) != null )
    {
        DivErrMsgStory.innerHTML = ERR_WRONG_INPUT.value;
        MsgStory.style.border = "1px solid red";
        return false;
    }
    
    if (( MsgName.value.length > 20 )  || ( MsgName.value.length <= 0 ) )
    {
        DivErrMsgName.innerHTML = ERR_WRONG_INPUT.value;
        MsgName.style.border = "1px solid red";
        return false;
    }    
    
    if (( MsgSurName.value.length > 20 )  || ( MsgSurName.value.length <= 0 ) )
    {
        DivErrMsgSurName.innerHTML = ERR_WRONG_INPUT.value;
        MsgSurName.style.border = "1px solid red";
        return false;
    }    
    
    if (( MsgLocation.value.length > 20 ) || ( MsgLocation.value.length <= 0 ) )
    {
        DivErrMsgLocation.innerHTML = ERR_WRONG_INPUT.value;
        MsgLocation.style.border = "1px solid red";
        return false;
    }
    
    if (( MsgTitle.value.length > 20 ) ||( MsgTitle.value.length <= 0 ) )
    {
        DivErrTitle.innerHTML = ERR_WRONG_INPUT.value;
        MsgTitle.style.border = "1px solid red";
        return false;
    }
    
    if (( MsgStory.value.length > 3000 ) ||( MsgStory.value.length <= 0 ) )
    {
        DivErrMsgStory.innerHTML = ERR_WRONG_INPUT.value;
        MsgStory.style.border = "1px solid red";
        return false;
    }
    
   
    
    return bValid;
}

function MoveToInnerUrl(  inUrl ,  inParam )
{

   
    var sPath = inUrl + inParam;
    
   
    return sPath;
}

function UpdateHiddenTowParam()
{

    var FilterRangeID =  document.getElementById("ctl00_MainContent_UCAccumulutor1_RangeSelectID");
    var ReportFormatSelectID =  document.getElementById("ctl00_MainContent_UCAccumulutor1_ReportFormatSelectID");    
    var HiddenFilter =  document.getElementById("ctl00_MainContent_UCAccumulutor1_HiddenFilter"); 
  
    HiddenFilter.value  = "Range" + "," + FilterRangeID.value + ";" + "AccumulutorReportType" + "," + ReportFormatSelectID.value + ";" ;
    
}

function UpdateHiddenOneParam(inLang)
{
    var DivBrandSelect =  document.getElementById("ctl00_MainContent_UCAccumulutor1_BrandSelect");
    var HiddenFilter =  document.getElementById("ctl00_MainContent_UCAccumulutor1_HiddenFilter");    
    
    if ( inLang == "HE" )
    {
    HiddenFilter.value  = "AccumulutorEnumTypeHe" +  "," + DivBrandSelect.value + ";" ;
    }
    else
    {
    HiddenFilter.value  = "Brand" +  "," + DivBrandSelect.value + ";" ;
    }
    
    
}


// here we define global variable
var ajaxdestination="";
var g_syear = "2000";

var active = 1;
var height ;

/* Star of  History Page     */

function HistoryLoadThankYouDiv (inDivObjID)
{
//debugger
//    var objArr = document.getElementById(inDivObjID).getElementsByTagName('div');   
//    alert(   objArr );
    
    
}



function CloseHistoryDiv(inObjID)
{

     var ObjOpen =  document.getElementById('Open' + inObjID);       
     var ObjClose =  document.getElementById('Close' + inObjID);  
          
         
     ObjOpen.style.visibility="hidden";        
     ObjOpen.style.display="none";        
     
     ObjClose.style.visibility="visible";        
     ObjClose.style.display="block";        
    
}

function OpenResponseDiv(inObjID)
{

     var ObjOpen =  document.getElementById('Open' + inObjID);       
     var ObjClose =  document.getElementById('Close' + inObjID);  
          
     ObjClose.style.visibility="hidden";        
     ObjClose.style.display="none";    
         
     ObjOpen.style.visibility="visible";        
     ObjOpen.style.display="block";        
      
     
}


function OpenHistoryDiv(inObjID)
{

     var ObjOpen =  document.getElementById('Open' + inObjID);       
     var ObjClose =  document.getElementById('Close' + inObjID);  
          
           ObjClose.style.visibility="hidden";        
     ObjClose.style.display="none";    
         
     ObjOpen.style.visibility="visible";        
     ObjOpen.style.display="block";        
     
   
        
        
      
     
}
function HideStoreRegionInfo(inObjID)
{

   clearTimeout(TO);
   var ObjInfoDiv =  document.getElementById("divRegionInfo_" + inObjID);       
   ObjInfoDiv.className  = "StoreRegionInfo";    
}


/* End of  History Page     */

function HideRegionInfo(inObjID)
{
   
    var ObjID =  inObjID.substring(0, inObjID.length - 11 );   
    var ObjInfoDiv =  document.getElementById("divRegionInfo_" + ObjID);       
    ObjInfoDiv.className  = "RegionInfo";    
}

function HideRegionItemInfo(inObjID)
{
   
    var ObjID =  inObjID.substring(0, inObjID.length - 15 );   
    var ObjInfoDiv =  document.getElementById("divRegionInfo_" + ObjID);       
    ObjInfoDiv.className  = "CloseRegionInfo";    
    
}

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}


var oMapx = 0;
var oMapy = 0;
function getPositionMouse(evt) {
    var cursor = { x: 0, y: 0 };
    var evt = evt || window.event;
    if (evt.pageX) { cursor.x = evt.pageX; }
    else {
        if (evt.clientX) {
            cursor.x = evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
        }
        else { cursor.x = 0; }
    }

    if (evt.pageY) { cursor.y = evt.pageY; }
    else {
        if (evt.clientY) {
            cursor.y = evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
        }
        else { cursor.y = 0; }
    }
    
    oMapx = cursor.x;
    oMapy = cursor.y;
}

function ShowStoreRegionAndDataItemInfo(evt, inObjID, direction, xSum, ySum) {
    var oIEVer = getInternetExplorerVersion();
    if (oIEVer <= 6 && oIEVer!=-1) {
        ShowStoreRegionItemInfo(inObjID, direction, xSum, ySum);
    }
    else {
        getPositionMouse(evt);

        clearTimeout(TO);
        var tmpobj = document.getElementById(inObjID);
        var ObjID = inObjID.substring(0, inObjID.length - 2);
        var ObjInfoDiv = document.getElementById("divRegionInfo_" + ObjID);

        ObjInfoDiv.className = "ShowStoreRegionInfo";
        ObjInfoDiv.style.position = "absolute";

        if (direction == "left") {
        }
        else {
            if (oIEVer > -1) {
                if (oIEVer >= 8) {
                    ObjInfoDiv.style.top = (oMapy - 215) + 'px';
                    ObjInfoDiv.style.left = (oMapx - 30) + 'px';
                }
                else {
                    if (oIEVer >= 7) {
                        ObjInfoDiv.style.top = (oMapy - 232) + 'px';
                        ObjInfoDiv.style.left = (oMapx - 45) + 'px';
                    }
                    else {
                        if (oIEVer <= 6) {
                            ObjInfoDiv.style.top = (oMapy - 232) + 'px';
                            ObjInfoDiv.style.left = (oMapx - 45) + 'px';
                        }
                    }
                }
            }
            else {
                ObjInfoDiv.style.top = (oMapy - 207) + 'px';
                ObjInfoDiv.style.left = (oMapx - 30) + 'px';
            }
        }
    }
}

function ShowStoreRegionItemInfo_v2(evt, inObjID, direction, xSum, ySum) {
    var oIEVer = getInternetExplorerVersion();
    if (oIEVer <= 6 && oIEVer!=-1) {
        ShowStoreRegionItemInfo(inObjID, direction, xSum, ySum);
    }
    else {
        getPositionMouse(evt);

        clearTimeout(TO);
        var tmpobj = document.getElementById(inObjID);
        var ObjID = inObjID.substring(0, inObjID.length - 2);
        var ObjInfoDiv = document.getElementById("divRegionInfo_" + ObjID);

        ObjInfoDiv.className = "ShowStoreRegionInfo";
        ObjInfoDiv.style.position = "absolute";

        if (direction == "left") {
            if (oIEVer > -1) {
                if (oIEVer >= 8) {
                    ObjInfoDiv.style.top = (oMapy-607) + 'px';
                    ObjInfoDiv.style.left = (oMapx-70) + 'px';
                }
                else {
                    if (oIEVer >= 7) {
                        ObjInfoDiv.style.top = (oMapy-634) + 'px';
                        ObjInfoDiv.style.left = (oMapx-73) + 'px';
                    }
                    else {
                        if (oIEVer <= 6) {
                            ObjInfoDiv.style.top = (oMapy) + 'px';
                            ObjInfoDiv.style.left = (oMapx) + 'px';
                        }
                    }
                }
            }
            else {
                ObjInfoDiv.style.top = (oMapy-608) + 'px';
                ObjInfoDiv.style.left = (oMapx-72) + 'px';
            }
        }
        else {
            if (oIEVer > -1) {
                if (oIEVer >= 8) {
                    ObjInfoDiv.style.top = (oMapy-630) + 'px';
                    ObjInfoDiv.style.left = (oMapx-284) + 'px';
                }
                else {
                    if (oIEVer >= 7) {
                        ObjInfoDiv.style.top = (oMapy-663) + 'px';
                        ObjInfoDiv.style.left = (oMapx-573) + 'px';
                    }
                    else {
                        if (oIEVer <= 6) {
                            ObjInfoDiv.style.top = (oMapy) + 'px';
                            ObjInfoDiv.style.left = (oMapx) + 'px';
                        }
                    }
                }
            }
            else {
                ObjInfoDiv.style.top = (oMapy-621) + 'px';
                ObjInfoDiv.style.left = (oMapx-286) + 'px';
            }
        }
    }
}


function ShowStoreRegionItemInfo(inObjID, direction, xSum, ySum) {
    clearTimeout(TO);
    var tmpobj = document.getElementById(inObjID);   
    var ObjID =  inObjID.substring(0, inObjID.length - 2  );    
    var ObjInfoDiv =  document.getElementById("divRegionInfo_" + ObjID);   
    //alert(xSum + " - " + ySum + " - " + );
    var parentOffsetTop = ObjInfoDiv.parentNode.firstChild.offsetTop;
    var parentOffsetLeft = ObjInfoDiv.parentNode.firstChild.offsetLeft;
    //alert(parentOffsetTop + " - " + parentOffsetLeft)
    
    var NewMarginTop = ySum + parentOffsetTop;
    var NewMarginLeft = xSum + parentOffsetLeft;
    var ObjCount = ObjInfoDiv.getElementsByTagName('div');
    var tmptop = NewMarginTop;
    var BoxH =   parseInt (  (ObjCount.length / 4) );
    
   
    //alert(xSum + " - " + parentOffsetLeft + " - " + (xSum + parentOffsetLeft));
    if( direction == "left" )
    {
        NewMarginTop = parseInt(NewMarginTop + 70);
        NewMarginLeft = parseInt(NewMarginLeft + 220 - (1280 - screen.width));
    }
    else
    {
        NewMarginTop = parseInt(NewMarginTop - 50);
        NewMarginLeft = parseInt(NewMarginLeft + 80 - (1280 - screen.width));
    }
    
    ObjInfoDiv.className = "ShowStoreRegionInfo";
    ObjInfoDiv.style.position = "absolute";

    ObjInfoDiv.style.top = NewMarginTop+ 'px';
    ObjInfoDiv.style.left = NewMarginLeft + 'px';
    
    if ( BoxH > 1 )
    {   
        //ObjInfoDiv.style.height += (( BoxH * 80)) + 'px';    
        //ObjInfoDiv.style.height += (( BoxH * 80));         
    }
    
}


function ShowRegionItemInfo(inObjID)
{
    //debugger
    
    var ObjPin =  document.getElementById(inObjID);
    var ObjID =  inObjID.substring(0, inObjID.length - 2  );    
    var ObjInfoDiv =  document.getElementById("divRegionInfo_" + ObjID);   
    var NewMarginTop = ObjPin.style.marginTop.substring( 0,ObjPin.style.marginTop.length - 2 );
    var NewMarginLeft = ObjPin.style.marginLeft.substring( 0,ObjPin.style.marginLeft.length - 2 );
    var ObjCount = ObjInfoDiv.getElementsByTagName('div');
    
    var BoxH = ObjCount.length / 4 ;
    
    //alert( "ObjCount : " + ObjCount.length);
    
    NewMarginTop = parseInt(NewMarginTop - 220 );
    NewMarginLeft = parseInt(NewMarginLeft - 100 );
    
    ObjInfoDiv.className  = "ShowRegionInfo";
    ObjInfoDiv.style.marginTop  = NewMarginTop+ 'px';
    ObjInfoDiv.style.marginLeft  = NewMarginLeft + 'px' ;
    
    if ( BoxH > 1 )
    {
        ObjInfoDiv.style.height += ( BoxH * 80) + 'px';        
    }
    
}


var currentRegionPopup = null;
function ShowRegionInfo(inObjID, direction,xSum,ySum)
{
    
    
    var ObjID =  inObjID.substring(0, inObjID.length - 2  );    
    var ObjInfoDiv =  document.getElementById("divRegionInfo_" + ObjID);   
    var NewMarginTop = ySum
    var NewMargin = 0;
    if(currentRegionPopup != null && currentRegionPopup != inObjID.substring(0, inObjID.length - 2 ) )
    {
       HideRegionInfo(currentRegionPopup+"RegionClose");
    }
    currentRegionPopup = inObjID.substring(0, inObjID.length - 2 );
    
    
    NewMargin  = xSum;
    
    var ObjCount = ObjInfoDiv.getElementsByTagName('div');
    
    
    
    
    
    ObjInfoDiv.className  = "ShowRegionInfo";
    
    if(direction == "left")
    {
        NewMarginTop = parseInt(NewMarginTop - 150 );
        NewMargin = parseInt(NewMargin - 20 );
        ObjInfoDiv.style.top  = NewMarginTop+ 'px';
        ObjInfoDiv.style.left  = NewMargin + 'px' ;
        
    }
    else
    {
        NewMarginTop = parseInt(NewMarginTop - 220 );
        NewMargin = parseInt(NewMargin - 300 );
        ObjInfoDiv.style.top  = NewMarginTop+ 'px';
        ObjInfoDiv.style.left  = NewMargin + 'px' ;       
    }
}

function ShowRegionInfo_v2(evt, inObjID, direction, xSum, ySum) {

    var oIEVer = getInternetExplorerVersion();
    if (oIEVer <= 6 && oIEVer!=-1) {
        ShowRegionInfo(inObjID, direction, xSum, ySum);
    }
    else {
        getPositionMouse(evt);

        var ObjID = inObjID.substring(0, inObjID.length - 2);
        var ObjInfoDiv = document.getElementById("divRegionInfo_" + ObjID);
        var NewMarginTop = ySum
        var NewMargin = 0;
        if (currentRegionPopup != null && currentRegionPopup != inObjID.substring(0, inObjID.length - 2)) {
            HideRegionInfo(currentRegionPopup + "RegionClose");
        }
        currentRegionPopup = inObjID.substring(0, inObjID.length - 2);


        NewMargin = xSum;

        var ObjCount = ObjInfoDiv.getElementsByTagName('div');
        ObjInfoDiv.className = "ShowRegionInfo";

        if (direction == "left") {
            if (oIEVer > -1) {
                if (oIEVer >= 8) {
                    ObjInfoDiv.style.top = (oMapy - 619) + 'px';
                    ObjInfoDiv.style.left = (oMapx - 72) + 'px';
                }
                else {
                    if (oIEVer >= 7) {
                        ObjInfoDiv.style.top = (oMapy-569) + 'px';
                        ObjInfoDiv.style.left = (oMapx-73) + 'px';
                    }
                    else {
                        if (oIEVer <= 6) {
                            ObjInfoDiv.style.top = (oMapy) + 'px';
                            ObjInfoDiv.style.left = (oMapx) + 'px';
                        }
                    }
                }
            }
            else {
                ObjInfoDiv.style.top = (oMapy-623) + 'px';
                ObjInfoDiv.style.left = (oMapx - 75) + 'px';
            }
        }
        else {
            if (oIEVer > -1) {
                if (oIEVer >= 8) {
                    ObjInfoDiv.style.top = (oMapy - 613) + 'px';
                    ObjInfoDiv.style.left = (oMapx - 678) + 'px';
                }
                else {
                    if (oIEVer >= 7) {
                        ObjInfoDiv.style.top = (oMapy-563) + 'px';
                        ObjInfoDiv.style.left = (oMapx-698) + 'px';
                    }
                    else {
                        if (oIEVer <= 6) {
                            ObjInfoDiv.style.top = (oMapy) + 'px';
                            ObjInfoDiv.style.left = (oMapx) + 'px';
                        }
                    }
                }
            }
            else {
                ObjInfoDiv.style.top = (oMapy-614) + 'px';
                ObjInfoDiv.style.left = (oMapx-688) + 'px';
            }
        }
    }
}

/*-------------------------------------------------------*/
// close all div's and change text to open
function FAQAcloseAllDiv(inDivName,Close, Open)
{
    
    var objDivsCloseAll = document.getElementsByTagName('div'); // get all div's
    var bClose = false;
    
    
    
    for (  i = 0; i < objDivsCloseAll.length ; i++ )
    {        
        var sObjID =  String(objDivsCloseAll[i].id);
         
         if ( sObjID != ( "FAQItem_" +   inDivName ))
         {
                 
            if ( sObjID.lastIndexOf("FAQItem_") >= 0 )
            { 
                var objCurrentDivArry = objDivsCloseAll[i].getElementsByTagName('div'); // get all child div of objDivsCloseAll
                
                for (  index = 0; index < objCurrentDivArry.length ; index++ )
                {
                    var sDivID  = String(objCurrentDivArry[index].id);
                    var sDivOpenIDArray  = objCurrentDivArry[index].getElementsByTagName('a');
                    
                    
                    for (  Aindex = 0; Aindex < sDivOpenIDArray.length ; Aindex++ )
                    {  
                        sDivOpenIDArray[Aindex].innerHTML = Open;                      
                    }
                    
                    if ( sDivID.lastIndexOf("FAQItemA_") >= 0 )
                    {                   
                        objCurrentDivArry[index].className = "FAQItemA";                                      
                    }
                    
                }
                    
            }
        }
    }
}


var currentOpenFaq = null;
var currentFaqSpace = null;
function FAQOpenDiv(FAQItemID,FAQSpace)
{
    var isEqual = 0;
    if(currentOpenFaq == FAQItemID)
    {
       document.getElementById(FAQItemID).style.display = "none";
       document.getElementById(FAQSpace).style.display = "block";
       currentOpenFaq = null;
       currentFaqSpace = null;
       isEqual = 1;
    }
   
    if(currentOpenFaq != null)
    {
        document.getElementById(currentOpenFaq).style.display = "none";
        document.getElementById(currentFaqSpace).style.display = "block";
        currentOpenFaq = FAQItemID;
        currentFaqSpace = FAQSpace;
    }
    
    if(isEqual == 0)
    {
        document.getElementById(FAQItemID).style.display = "Block";
        document.getElementById(FAQSpace).style.display = "none";
        currentOpenFaq = FAQItemID;
        currentFaqSpace = FAQSpace;
    }
}    
    
    
   /* 
    
    var objFirst = document.getElementById("FAQItemA_" + inDivName);        
    var children = document.getElementById('FAQItemA_' + inDivName).getElementsByTagName('div');    
    var objOpenDiv = document.getElementById("Open_" + inDivName).getElementsByTagName('a');
    var bFirstObj = false;
    var objDivsCloseAll = document.getElementsByTagName('div');
        
    FAQAcloseAllDiv(inDivName, Close, Open);
         
    var objToOpen = document.getElementById("FAQItemA_" + inDivName );    
     var objToOpenLLink = document.getElementById("Open_" + inDivName ).getElementsByTagName('a');        
     var objToOpenArr = objToOpen.getElementsByTagName('div');         
     var objDivToOpen = document.getElementById("FAQItemA_" + inDivName );    
     
   
    if ( objToOpenLLink[0].innerHTML == Open )
    {
        objToOpenArr[0].className  = "FAQItemAOpen"; 
        objDivToOpen.className  = "FAQItemAOpen"; 
        objToOpenLLink[0].innerHTML = Close;    
    }
    else
    {  
        objToOpenArr[0].className  = "FAQItemA";  
        objDivToOpen.className  = "FAQItemA";  
        objToOpenLLink[0].innerHTML = Open;    
    }        
}*/

function ResponsePlusOne(inDivName) 
{    
    alert('ResponsePlusOne');
    
    var SlideForm = 'RsponseSlideForm';
    
    try
    {
        if(height <= 20) 
        {          
            document.getElementById(SlideForm).style.visibility="visible";                
            height = height + 10;          
            
              
            
            document.getElementById(SlideForm).style.height=height + 'px';            
            setTimeout("divPlusOne(" + SlideForm + ")",50);
        }
    }
    catch( e )
    {
        
    }
}



function ContactUs_RsponseShowFillForm()
{    
    var SelectTopic = document.getElementById('ctl00_MainContent_SelectTopic');        
    var ResponseFillForm = document.getElementById('ResponseForm_' + SelectTopic.value);    
    var ResponseSlideForm = document.getElementById('RsponseSlideForm_' + SelectTopic.value);
        
    ResponseSlideForm.innerHTML = ResponseFillForm.innerHTML;
   
    ResponseSlideForm.style.visibility="visible";    
    alert('ResponseSlideForm');
    alert(ResponseSlideForm.innerHTML);
    height = 0;
    
    ResponsePlusOne('RsponseSlideForm_' );
    
}



function slideContent(inputId,direction)
{
	
	
	
	var obj =document.getElementById( inputId);
	var contentObj = document.getElementById( inputId);
	height = obj.clientHeight;
	if(height==0)height = obj.offsetHeight;
	height = height + direction;
	rerunFunction = true;
	if(height>contentObj.offsetHeight){
		height = contentObj.offsetHeight;
		rerunFunction = false;
	}
	if(height<=1){
		height = 1;
		rerunFunction = false;
	}

	obj.style.height = height + 'px';
	var topPos = height - contentObj.offsetHeight;
	if(topPos>0)topPos=0;
	contentObj.style.top = topPos + 'px';
	if(rerunFunction){
		setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer);
	}else{
		if(height<=1){
			obj.style.display='none'; 
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('RsponseSlideForm').style.display='block';
				document.getElementById('RsponseSlideForm').style.visibility='visible';
				slideContent('RsponseSlideForm',dhtmlgoodies_slideSpeed);				
			}else{
				dhtmlgoodies_slideInProgress = false;
			}
		}else{
			dhtmlgoodies_activeId = inputId;
			dhtmlgoodies_slideInProgress = false;
		}
	}
}



function divPlusOne(inDivName) 
{    
    var SlideForm = 'SlideForm';
    
    try
    {
        if(height <= 100) 
        {          
            document.getElementById(SlideForm).style.visibility="visible";                
            height = height + 10;          
            alert(height);
            document.getElementById(SlideForm).style.top  = height + 'px';       
            document.getElementById(SlideForm).style.height=height + 'px';            
            setTimeout("divPlusOne(" + SlideForm + ")",50);
        }
    }
    catch( e )
    {
        
    }
}
function ContactUs_ShowFillForm()
{
    var SelectTopic = document.getElementById('ctl00_MainContent_SelectTopic');    
    var FillForm = document.getElementById('FillForm_' + SelectTopic.value );
    var SlideForm = document.getElementById('SlideForm');
    
    SlideForm.innerHTML = FillForm.innerHTML;
    SlideForm.style.display="inline";   
    SlideForm.style.visibility="visible";   
    //SlideForm.style.top  = "-50px"; 
    //SlideForm.style.height='50px'; 
    //SlideForm.style.width='0px'; 
     var MainDiv = document.getElementById('MainPage' );
     MainDiv.style.top  = "-50px"; 
     
    
    
    //slideContent('SlideForm',1);
    
   divPlusOne('MainPage');
    
}

function ShowDiv( inDivName)
{  
    var div = document.getElementById(inDivName);
    
    div.style.display = "inline";
    
    var AllDecade = document.getElementById(inDivName);
    AllDecade.InnerHtml = div.InnerHtml;    
    
    var divArray = document.getElementsByTagName('div');
    
    for (var i = 0, ele; ele = divArray[i]; i++) 
    {
        var sID = ele.id;
        if ( sID )
        {       
            if (( sID.indexOf('MainDiv_',0)  == 0 ) &&   ( sID  != inDivName ))
            {
                var HideDiv = document.getElementById(sID);
                HideDiv.style.display = "none";               
            }
        }        
    }  
}

function getdata(url,DivName) 
{ 
    // get data from source (url)
 
  g_syear = url;
     if (window.XMLHttpRequest) // if Mozilla, Safari etc
     {
        xmlhttp = new XMLHttpRequest();
     }
     else 
     {
        if (window.ActiveXObject)
        { // if IE
            try 
            {
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
            }
            catch (e)
            { 
                try
                {
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
                }
                catch (e){}
            }
         }
         else
         {
            return false;
         }
         
   }
   
    // we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
    ajaxdestination=DivName;
    xmlhttp.onreadystatechange = triggered; // when request finished, call the function to put result to destination DIV
    
    xmlhttp.open("GET", url);
    xmlhttp.send(null);
   //shiftOpacity(DivName,200);
    return false;
}

      var duration = 1000;  /* 1000 millisecond fade = 1 sec */
      var steps = 50;       /* number of opacity intervals   */
      var delay = 5000;     /* 5 sec delay before fading out */

      /* set the opacity of the element (between 0.0 and 1.0) */
      function setOpacity(level) {
	    var element = document.getElementById(ajaxdestination);
        element.style.opacity = level;
        element.style.MozOpacity = level;
        element.style.KhtmlOpacity = level;
        element.style.filter = "alpha(opacity=" + (level * 100) + ");";
      }

      function fadeIn(){
        for (i = 0; i <= 1; i += (1 / steps)) {
        
          setTimeout("setOpacity(" + i + ")", i * duration);
        }
       
      }
function triggered() 
{ 
   
  if ((xmlhttp.readyState == 4) || (xmlhttp.readyState == 200))
  { 
    var element = document.getElementById(ajaxdestination);
    if ( element )
    {
       
        document.getElementById(ajaxdestination).innerHTML =xmlhttp.responseText;
         changeSelectedYear("TimeLine"+g_syear);
        
    }
    //document.getElementById('ctl00_MainContent_Cube1').src = "http://www.walla.co.il"
    
   //cfadeIn();
   
   
  }
   
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
/*
 function fadeIn(){
        for (i = 0; i <= 1; i += (1 / steps)) {
          setTimeout("setOpacity(" + i + ")", i * duration);
        }
        //setTimeout("fadeOut()", delay);
      }*/
function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	//if(document.getElementById(id).style.opacity == 0) {
	    
		opacity(id, 0, 100, millisec);
	//} else {
	//	opacity(id, 100, 0, millisec);
	//}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

var currentYear = "ctl00_MainContent_TimeLine2000";

function  changeSelectedYear(imageID)
{
    var selectedYear = document.getElementById(imageID.id);
    var lastYear = document.getElementById(currentYear);
    
    if(selectedYear == null)
    {
        if(imageID == "TimeLine2000")
        {
            selectedYear = document.getElementById("ctl00_MainContent_TimeLine2000");
        }
        else
        {
            selectedYear = document.getElementById(imageID);
        }
    }
    
 //   alert(currentYear);
   
    selectedYear.src = selectedYear.src.replace(".gif", "_selected.gif");
    lastYear.src = lastYear.src.replace("_selected.gif", ".gif");
    
   // alert(selectedYear.src);
    currentYear = selectedYear.id;
}



function fade()
{
    var fade=0,
    logo=document.getElementById("MainFade").style,
    
    ms=(logo.opacity==0)?0:1,pace=setInterval(Fade,20);

        function Fade()
        {
            if(fade<100)
            {
                fade+=1;
                if(ms)
                    logo.filter="alpha(opacity="+fade+")";
                else 
                    logo.opacity=(fade/100)
            }
            else 
            clearInterval(pace)
        }
    
}


function SendEmail()
{

 var disclamer = document.getElementById("disclamerInput");
        //debugger;
    if ( ValidateBrand() )
    {
        if(disclamer.checked == true)
        {
            document.getElementById("ctl00_MainContent_UCdisclamer1_disError").style.display = "none";
            document.forms[0].submit();
        }
        else
        {
            document.getElementById("ctl00_MainContent_UCdisclamer1_disError").style.display = "block"; 
        }
    }
  
}



//function SendEmail(formName)
//{

// var disclamer = document.getElementById("disclamerInput");
//        //debugger;
//    if ( ValidateBrand() )
//    {
//        if(disclamer.checked == true)
//        {
//            document.getElementById("ctl00_MainContent_UCdisclamer1_disError").style.display = "none";
//            document.forms[formName].submit();
//        }
//        else
//        {
//            document.getElementById("ctl00_MainContent_UCdisclamer1_disError").style.display = "block"; 
//        }
//    }
//  
//}



function sendEmailAlerts()
{
 var disclamer = document.getElementById("disclamerInput");
        
    if(disclamer.checked == true)
    {
        document.getElementById("ctl00_MainContent_UCdisclamer1_disError").style.display = "none";
        document.forms[0].submit();
    }
    else
    {
        document.getElementById("ctl00_MainContent_UCdisclamer1_disError").style.display = "block"; 
    }
}








function SendPersonalEmail()
{
  document.forms[0].submit();
}





function ValidateBrand()
{

    var bValid = true;
    var ERR_STRING_TO_LONG =  document.getElementById("ctl00_MainContent_ERR_STRING_TO_LONG");
    var ERR_WRONG_INPUT =  document.getElementById("ctl00_MainContent_ERR_WRONG_INPUT");
    var ERR_NOT_VALID_EMAIL =  document.getElementById("ctl00_MainContent_ERR_NOT_VALID_EMAIL");
    var oDivErrMsg =  document.getElementById("ctl00_MainContent_DivErrMsg");
    
    
    var InputNameID =  document.getElementById("ctl00_MainContent_InputNameID");
    var InputSurNameID =  document.getElementById("ctl00_MainContent_InputSurNameID");
    var InputRegionID =  document.getElementById("ctl00_MainContent_InputRegionID");
    var InputEmailID =  document.getElementById("ctl00_MainContent_email");
    var InputContectID =  document.getElementById("ctl00_MainContent_InputContectID");
    var lblErr =  document.getElementById("ctl00_MainContent_lblErr");
    var oPhone = document.getElementById('ctl00_MainContent_InputPhoneID');
    var re = new  RegExp("<(.|\n)*?>" );;
    
    
    InputNameID.style.border =  "1px solid Gray";
    InputSurNameID.style.border =  "1px solid Gray";
    InputRegionID.style.border = "1px solid Gray";
    InputEmailID.style.border =  "1px solid Gray";
    InputContectID.style.border =  "1px solid Gray";  

    lblErr.value="" ;
    
    /*INput Name*/
    if (InputNameID.value.length > 40 )
    {
        lblErr.innerHTML = ERR_STRING_TO_LONG.value;
        InputNameID.style.border = "1px solid red";
        oDivErrMsg.className = "inputNamePos";
        return false;
    }  
   
    if ( re.exec(InputNameID.value) != null || InputNameID.value.length == 0 )
    {
        lblErr.innerHTML = ERR_WRONG_INPUT.value;
        InputNameID.style.border = "1px solid red";
        oDivErrMsg.className = "inputNamePos";
        return false;
    }
    /*INput SurName*/
    if (InputSurNameID.value.length > 40 )
    {
        lblErr.innerHTML = ERR_STRING_TO_LONG.value;
        InputSurNameID.style.border = "1px solid red";
        oDivErrMsg.className = "inputNamePos";
        return false;
    }  
   
    if ( re.exec(InputNameID.value) != null || InputSurNameID.value.length == 0 )
    {
        lblErr.innerHTML = ERR_WRONG_INPUT.value;
        InputSurNameID.style.border = "1px solid red";
        oDivErrMsg.className = "inputNamePos";
        return false;
    }
   
   /*Input Email*/       
    if ( (InputEmailID.value.indexOf(".") < 2) && (InputEmailID.value.indexOf("@") < 0) )
    {  
        lblErr.innerHTML    = ERR_NOT_VALID_EMAIL.value;
        InputEmailID.style.border = "1px solid red";
        oDivErrMsg.className = "inputEmailPos";
        return false;
    }
    if ( re.exec(InputEmailID.value) != null || InputEmailID.value.length == 0)
    {
        lblErr.innerHTML = ERR_WRONG_INPUT.value;
        InputEmailID.style.border = "1px solid red";
        oDivErrMsg.className = "inputEmailPos";    
        return false;
    }
    
    
    if (!checkPhone(oPhone.value)){
        oPhone.style.borderColor = "red";
        oPhone.style.backgroundColor = "yellow";
        return false;
    }
    else{
        oPhone.style.borderColor = "gray";
        oPhone.style.backgroundColor = "#ffffff";
        
    }
   /*Input Region*/
    if ( InputRegionID.value.length > 20 )
    {
        lblErr.innerHTML = ERR_STRING_TO_LONG.value;
        InputRegionID.style.border = "1px solid red";
        oDivErrMsg.className = "inputRegionPos";
        return false;
    }
    if ( re.exec(InputRegionID.value) != null || InputRegionID.value.length == 0)
    {
        lblErr.innerHTML = ERR_WRONG_INPUT.value;
        InputRegionID.style.border = "1px solid red";
        oDivErrMsg.className = "inputRegionPos";
        return false;
    }
   
     /*Input content*/  
    if ( InputContectID.value.length > 3000 )
    {
        oDivErrMsg.innerHTML = ERR_STRING_TO_LONG.value;
        InputContectID.style.border = "1px solid red";
        oDivErrMsg.className = "inputContentPos";
        return false;
    }
    if ( re.exec(InputContectID.value) != null || InputContectID.value.length == 0 )
    {
        lblErr.innerHTML = ERR_WRONG_INPUT.value;
        InputContectID.style.border = "1px solid red";
        oDivErrMsg.className = "inputContentPos";
        return false;
    }
    return bValid;
}

var currenActivePopUp = null;
function showBrandsPopUp(popupID, ID)
{
    var popup = document.getElementById(popupID);
    var oLeftBefore = popup.offsetLeft;
    popup.className= "showBrandsPopUp";
    popup.style.right = "65px";
    popup.style.left = "65px";
    var oLeftAfter = popup.offsetLeft;
    if (oLeftAfter < 0) {
        var oIEVer = getInternetExplorerVersion();
        if (oIEVer == -1 || oIEVer == 8) {
            popup.style.right = "-230px";
            popup.style.left = "-230px";
        }
        else {
            if (oIEVer == 7) {
                popup.style.right = "-340px";
                popup.style.left = "-340px";
            }
            else {
                if (oIEVer == 6) {
                    popup.style.right = "-340px";
                    popup.style.left = "-340px";
                }
            }
        }
    }
    
    if(currenActivePopUp != null && currenActivePopUp != popupID )
    {
    hideBrandsPopUp(currenActivePopUp);
    }
    currenActivePopUp = popupID; 
}
function isInside(cont, e)
{
	var answer = false;
	var mousePos = mouseCoords(e);
	var contLocation = getPosition(cont);
	if(mousePos.x >= contLocation.x &&
		mousePos.x <= contLocation.x + cont.offsetWidth &&
		mousePos.y >= contLocation.y &&
		mousePos.y <= contLocation.y + cont.offsetHeight)
	{
		answer = true;
		
	}	
	return answer;
}
function hideBrandsPopUp(popupID, e)
{
	var popup =  document.getElementById(popupID);
	//if(!isInside(popup, e))
	{
		popup.className= "popUpDivSizes";	
	}

}
function getPosition(obj)
{
	var curleft = 0, curtop = 0;
	if(obj.offsetParent)
	while(1) 
	{
		curleft += obj.offsetLeft;
		curtop += obj.offsetTop;
		if(!obj.offsetParent)
			break;
		obj = obj.offsetParent;
	}
	else
	{
		if(obj.x)
			curleft += obj.x;
		if(obj.y)
		curtop += obj.y;
	}
	return new Point(curleft, curtop);
}
function Point(x,y)
{
	this.x = x;
	this.y = y;
}
function mouseCoords(e)
{
	var x,y;
	ev = e || window.event;
	//alert(ev);
	if(ev.pageX || ev.pageY) // moz
	{
		x = ev.pageX;
		y = ev.pageY;
	}
	else // ie
	{
		x = ev.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		y = ev.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	return new Point(x, y);
}
/*
function IsInPopupRange()
{
	var posX = findPosX(popup);
	var posY = findPosY(popup);
	var xLeft = posX;
	var xRight = posX + popup.clientWidth;
	var yTop = posY;
	var yBottom = posY + popup.clientHeight;
	return 
}
*/

function findPosX(obj)
{
	var curleft = 0;
	while (obj.offsetParent)
	{
		curleft += obj.offsetLeft
		obj = obj.offsetParent;
	}
	return curleft;
}
function findPosY(obj)
{
	var curtop = 0;
	while (obj.offsetParent)
	{
		curtop += obj.offsetTop
		obj = obj.offsetParent;
	}
	return curtop;
}


/*******Our Brands */

function SetOpacity( inObj ,inShow )
{
    if( inObj != null)
    {
        inObj.style.opacity = inShow/100;
        inObj.style.MozOpacity = inShow/100;
        inObj.style.KhtmlOpacity = inShow/100;                
        inObj.style.filter = "alpha(opacity=" + inShow + ");";
    }
}
var x;
function CheckImage(inRegion, inGroupName)
{
    var ImgToChange = new Array()
    var ImgPinToChange = new Array();
    var PicDiv =  document.getElementById("SmallPicDiv");
    ImgToChange = PicDiv.getElementsByTagName("img");
    /*var PicPinDiv =  document.getElementById("ctl00_MainContent_WorldMap");
    ImgPinToChange = PicPinDiv.getElementsByTagName("img");
    
    for ( k = 0; k < ImgPinToChange.length ; k++)
       {
         if ((ImgPinToChange[k].getAttribute("Region").indexOf(inRegion) >= 0) && (inGroupName == "all"))
        {
             SetOpacity(ImgPinToChange[k],100);
        }
         else if ((ImgPinToChange[k].getAttribute("Region").indexOf(inRegion) >= 0) && (ImgPinToChange[k].getAttribute("Groupname") == inGroupName))
        {    
                SetOpacity(ImgPinToChange[k],100);
        }             
         else if ((inRegion == "all") && (ImgPinToChange[k].getAttribute("Groupname") == inGroupName))
        {
            SetOpacity(ImgPinToChange[k],100);
        }
         else if ((inRegion == "all") && (inGroupName == "all"))
        {
            SetOpacity(ImgPinToChange[k],100);
        }
         else
        {
         SetOpacity(ImgPinToChange[k],0);
        }
      }     */        
    
    for (  i = 0; i < ImgToChange.length ; i++ )
    {
        
        var regions = new Array();
        if (ImgToChange[i].getAttribute("Region") != null)
        {
            regions = ImgToChange[i].getAttribute("Region").split(",");
        }
        var isInRegion = false;
        for( j = 0 ; j < regions.length ; j++ )
        {
            if( regions[j] == inRegion )
            {
                isInRegion = true;
            }
        }
        if ((isInRegion) && (inGroupName == "all" || inGroupName == "הכל"))
        {
        
            if (ImgToChange[i].getAttribute("Region") != null)
            {
               SetOpacity(ImgToChange[i],100);
               x= ImgToChange[i].getAttribute("PName");
               ImgToChange[i].onclick = function() { OpenInfoDiv(x);};
            }
        }
        else if ((isInRegion) && (ImgToChange[i].getAttribute("Groupname") == inGroupName))
        {    
            if (ImgToChange[i].getAttribute("Region") != null)
            {
               SetOpacity(ImgToChange[i],100);  x= ImgToChange[i].getAttribute("PName");
              ImgToChange[i].onclick = function() { OpenInfoDiv(x);};
            }
        }
        else if ((inRegion == "all" || inRegion == "הכל") && (ImgToChange[i].getAttribute("Groupname") == inGroupName))
        {
            if (ImgToChange[i].getAttribute("Region") != null)
            {
               SetOpacity(ImgToChange[i],100);  
                x= ImgToChange[i].getAttribute("PName");
             ImgToChange[i].onclick = function() { OpenInfoDiv(x);};
            }
        }
        else if ((inRegion == "all" || inRegion == "הכל") && (inGroupName == "all" || inGroupName == "הכל"))
        {
            if (ImgToChange[i].getAttribute("Region") != null)
            {
              SetOpacity(ImgToChange[i],100); 
               x= ImgToChange[i].getAttribute("PName");
              ImgToChange[i].onclick = function() { OpenInfoDiv(x);};
            }
        }
        else
        {
            if (ImgToChange[i].getAttribute("Region") != null)
            {
                SetOpacity(ImgToChange[i],20);
                ImgToChange[i].onclick = function() { DoNothing; };
            }
        }
    }
}

function DoNothing(x)
{

}

function ChangePics(region,GroupName)
{
   CheckImage(region,GroupName);
}



function OpenInfoDiv(sName)
{
     var DivToclose = new Array();
      var iOpacity;
     var Div =  document.getElementById("SmallPicDiv");
  
      DivToclose = Div.getElementsByTagName("div");
     for ( i = 0; i < DivToclose.length ; i++)
        {
        if(DivToclose[i].id != "" && DivToclose[i].id != 'ctl00_MainContent_SmallPicDivEx' && DivToclose[i].id != 'ctl00_MainContent_SmallPicDivIn' )
        
        {
            if (DivToclose[i].id != sName + "a" )
            {
            CloseInfoDiv(DivToclose[i].id);
            }
            else
            {
              var DivWithInfo = document.getElementById(sName+ "a");
                 DivWithInfo.className = "thumbnail_click";
              
            }
         }
        
       
     }
}
    

function CloseInfoDiv(sInfoDivId)
{
    var x = document.getElementById(sInfoDivId)
    x.className = "thumbnail";
}

//if call to the function dircertly
function CloseInfoHref(sInfoDivId)
{
    var x = document.getElementById(sInfoDivId)
    x.className = "thumbnail";
}

function GetOpacity(sObjName)
{
    if (document.getElementById(sObjName).filters.alpha.opacity != null)
    {
        var iOpacity = document.getElementById(sObjName).filters.alpha.opacity;
    }
return iOpacity;
}
/* 
  data = ['achla',
        'sababa',
        'שוקולד פרה',
        'קפה עלית'].sort();


AutoComplete_Create('ctl00_MainContent_SearchBox', data);
*/


function changeBrandBackGroundColor (Color)
{
    
    try
    {
        document.getElementById("ctl00_MainContent_brandPageWarpID").style.backgroundColor = Color;
        document.getElementById("ctl00_tvArea").style.backgroundColor = Color;
        document.getElementById("fromMasterContentID").style.width = "1000px";
        document.getElementById("bottomAreaWarp").style.backgroundColor = "white";
        document.getElementById("upperBG").style.backgroundColor = Color;
        
    }
    catch(e)
    {
        try
        {
            document.getElementById("ctl00_MainContent_brandPageWarpID").style.backgroundColor = '#' + Color;
            document.getElementById("ctl00_tvArea").style.backgroundColor = '#' + Color;
            document.getElementById("fromMasterContentID").style.width = "1000px";
            document.getElementById("bottomAreaWarp").style.backgroundColor = "white";
            document.getElementById("upperBG").style.backgroundColor = '#' + Color;
            
        }
        catch(ex)
        {
            
        }
    }
    
    
}

function changeBackGroundColorUpper (Color,Width)
{
    try
    {
        document.getElementById("upperBG").style.backgroundColor = '#' + Color; 
    }
    catch(e)
    {
        try
        {
            document.getElementById("upperBG").style.backgroundColor = Color; 
        }
        catch(ex)
        {
        }
    }
    if(Width)
    {
        document.getElementById("upperBG").style.width = Width;
    }
}

function changeBrandTextColor (Color)
{
    document.getElementById("ctl00_MainContent_brandPageWarpID").style.color = Color;
    if(document.getElementById("headerZone1") != null)
    {
        document.getElementById("headerZone1").style.color = Color;
    }
    
    if(document.getElementById("headerZone2") != null)
    {
        document.getElementById("headerZone2").style.color = Color;
    }
    
    if(document.getElementById("textZone1") != null)
    {
        document.getElementById("textZone1").style.color = Color;
    }
    
    if(document.getElementById("textZone2") != null)
    {
        document.getElementById("textZone2").style.color = Color;
    }

    var categoryCubeID = 1;

    while (document.getElementById("categoryHeader" + categoryCubeID) != null)
    {
        document.getElementById("categoryHeader" + categoryCubeID).style.color = Color;
        categoryCubeID++;
    }
    

}



function createThumbnails (maxWidth,maxHeight,tagId)
{
    var MainTable  = document.getElementById(tagId);
    var Images   = MainTable.getElementsByTagName("img");

    var i = 0;
    for(i=0; i < Images.length; i++)
    {
        while(Images[i].width > maxWidth || Images[i].height > maxHeight)
        {
            Images[i].width = parseInt(Images[i].width * 0.9);
            Images[i].height = parseInt(Images[i].height * 0.9);
        }
    }
}




function printIt(content)
{

    w=window.open('about:blank',"mywindow1",'status=1,width=350,height=250');
    w.document.open();
    w.document.write("<html><img src='" + content+"'>");
    w.document.writeln("<script>window.print();</"+"script>");
    w.document.writeln("</html>");
    w.document.close();
    w.close();

}

function switchTabStyle(clickedTab,tabid) {

  for (tabCounter = 0; tabCounter < clickedTab.parentNode.childNodes.length; tabCounter++)
    {

        if (clickedTab.parentNode.childNodes[tabCounter].nodeName == "LI") 
        {
             clickedTab.parentNode.childNodes[tabCounter].className = "LIDefault";
             clickedTab.parentNode.childNodes[tabCounter].childNodes[0].className = "ADefault";
             clickedTab.parentNode.childNodes[tabCounter].childNodes[0].childNodes[0].className = "ASpanDefault";

        }
    }    

    clickedTab.className = "LISelected";
    clickedTab.childNodes[0].className = "ASelected";
    clickedTab.childNodes[0].childNodes[0].className = "ASpanSelected";

    var tabidToShow = "tab" + tabid;

    for (tabContentContainer = 0; tabContentContainer < document.getElementById("TabsContainer").childNodes.length; tabContentContainer++) {
      
        if (document.getElementById("TabsContainer").childNodes[tabContentContainer].nodeName == "DIV") 
        {
            document.getElementById("TabsContainer").childNodes[tabContentContainer].className = "HiddenTabContent";
            if (document.getElementById("TabsContainer").childNodes[tabContentContainer].id == tabidToShow)
                document.getElementById("TabsContainer").childNodes[tabContentContainer].className = "VisibleTabContent";

        }
       
    }

}


function setImagesAlignmentPerImage(ImagesID,maxHeight)
{
	var difference = 0 ; 
	if(ImagesID.height < maxHeight )
        {
            difference = maxHeight - ImagesID.height;
        }
        else
        {
            difference = 0 ;
        }
        
        ImagesID.style.marginTop = difference /2 + "px" ;
}


function setImagesAlignment(ImagesID,maxHeight)
{
    var carusel = document.getElementById(ImagesID);
    var caruselImages = carusel.getElementsByTagName('img');
    var i = 0 ; 
    var difference = 0 ; 

     
   for(i=0; i <  caruselImages.length; i++)
   {
    if(caruselImages[i].className != "popUpBrandImage" && caruselImages[i].className != "BottompopUpBrandImage" && caruselImages[i].className != "BottomCenterImage")
    {
        if(caruselImages[i].height < maxHeight )
        {
            difference = maxHeight - caruselImages[i].height;
        }
        else
        {
            difference = 0 ;
        }
        
        caruselImages[i].style.marginTop = difference /2 + "px" ;
    }
   }
}

function start(elem)
{
    elem.scrollamount = "1";
}

function stop(elem)
{
    elem.scrollamount = "0";
}

