var getTransferObjectFORLOGIN = function(){    return null;    };
if(window.ActiveXObject){
    // Check if the browser has support for ActiveXObject (IE Usually) 
    try{ 
        // Check for the new version of XMLHttp compoment 
        var x= new ActiveXObject("MSXML2.XMLHTTP"); 
        getTransferObjectFORLOGIN = function(){ return new ActiveXObject("MSXML2.XMLHTTP"); }
        delete x;
    }catch(_ex){ 
        try{ // Check for late version of XMLHTTP compoment 
            var x = new ActiveXObject("Microsoft.XMLHTTP"); 
            getTransferObjectFORLOGIN= function(){ return new ActiveXObject("Microsoft.XMLHTTP"); }
            delete x;
        }catch(ex){
            // Otherwise the version of IE is too old 
        } 
    } 
}else if(window.XMLHttpRequest){
    // XMLHttpRequest object supported by Opera, Firefox and Safari - may too in IE 7. 
    getTransferObjectFORLOGIN = function(){ return new XMLHttpRequest(); }
}


var getTransferObject = function(){    return null;    };
if(window.ActiveXObject){
    // Check if the browser has support for ActiveXObject (IE Usually) 
    try{ 
        // Check for the new version of XMLHttp compoment 
        var x= new ActiveXObject("MSXML2.XMLHTTP"); 
        getTransferObject = function(){ return new ActiveXObject("MSXML2.XMLHTTP"); }
        delete x;
    }catch(_ex){ 
        try{ // Check for late version of XMLHTTP compoment 
            var x = new ActiveXObject("Microsoft.XMLHTTP"); 
            getTransferObject = function(){ return new ActiveXObject("Microsoft.XMLHTTP"); }
            delete x;
        }catch(ex){
            // Otherwise the version of IE is too old 
        } 
    } 
}else if(window.XMLHttpRequest){
    // XMLHttpRequest object supported by Opera, Firefox and Safari - may too in IE 7. 
    getTransferObject = function(){ return new XMLHttpRequest(); }
}


function showProdDesc(id)
{
	document.getElementById("prodDesc"+id).style.display = "inline";
}


function hideProdDesc(id)
{
	document.getElementById("prodDesc"+id).style.display = "none";
}


function overCat(id)
{
	document.getElementById("cat"+id).style.textDecoration = "underline";
}


function outCat(id)
{
	document.getElementById("cat"+id).style.textDecoration = "none";
}

function UTF8URLEncode(val)
{
	var output;
	
	output = val;
	output = find_and_replace_all("א", "%d7%90", output);
    output = find_and_replace_all("ב", "%d7%91", output);
    output = find_and_replace_all("ג", "%d7%92", output);
    output = find_and_replace_all("ד", "%d7%93", output);
    output = find_and_replace_all("ה", "%d7%94", output);
    output = find_and_replace_all("ו", "%d7%95", output);
    output = find_and_replace_all("ז", "%d7%96", output);
    output = find_and_replace_all("ח", "%d7%97", output);
    output = find_and_replace_all("ט", "%d7%98", output);
    output = find_and_replace_all("י", "%d7%99", output);
    output = find_and_replace_all("כ", "%d7%9b", output);
    output = find_and_replace_all("ל", "%d7%9c", output);
    output = find_and_replace_all("מ", "%d7%9e", output);
    output = find_and_replace_all("נ", "%d7%a0", output);
    output = find_and_replace_all("ס", "%d7%a1", output);
    output = find_and_replace_all("ע", "%d7%a2", output);
    output = find_and_replace_all("פ", "%d7%a4", output);
    output = find_and_replace_all("צ", "%d7%a6", output);;
    output = find_and_replace_all("ק", "%d7%a7", output);
    output = find_and_replace_all("ר", "%d7%a8", output);
    output = find_and_replace_all("ש", "%d7%a9", output);
    output = find_and_replace_all("ת", "%d7%aa", output);
    output = find_and_replace_all("ך", "%d7%9a", output);
    output = find_and_replace_all("ם", "%d7%9d", output);
    output = find_and_replace_all("ן", "%d7%9f", output);
    output = find_and_replace_all("ף", "%d7%a3", output);
    output = find_and_replace_all("ץ", "%d7%a5", output);
    output = find_and_replace_all("´", "%b4", output);
    output = find_and_replace_all("´", "%c2", output);
    output = find_and_replace_all("-", "%2d", output);
    output = find_and_replace_all(" ", "+", output);
	
	return output;

}
function UTF8URLDecode(val)
{
	var output;
	
	output = val;
	output = find_and_replace_all("%d7%90", "א", output);
    output = find_and_replace_all("%d7%91", "ב", output);
    output = find_and_replace_all("%d7%92", "ג", output);
    output = find_and_replace_all("%d7%93", "ד", output);
    output = find_and_replace_all("%d7%94", "ה", output);
    output = find_and_replace_all("%d7%95", "ו", output);
    output = find_and_replace_all("%d7%96", "ז", output);
    output = find_and_replace_all("%d7%97", "ח", output);
    output = find_and_replace_all("%d7%98", "ט", output);
    output = find_and_replace_all("%d7%99", "י", output);
    output = find_and_replace_all("%d7%9b","כ",  output);
    output = find_and_replace_all("%d7%9c", "ל", output);
    output = find_and_replace_all("%d7%9e", "מ", output);
    output = find_and_replace_all("%d7%a0", "נ", output);
    output = find_and_replace_all("%d7%a1", "ס", output);
    output = find_and_replace_all("%d7%a2", "ע", output);
    output = find_and_replace_all("%d7%a4", "פ", output);
    output = find_and_replace_all("%d7%a6", "צ", output);;
    output = find_and_replace_all("%d7%a7", "ק", output);
    output = find_and_replace_all("%d7%a8", "ר", output);
    output = find_and_replace_all("%d7%a9", "ש", output);
    output = find_and_replace_all("%d7%aa", "ת", output);
    output = find_and_replace_all("%d7%9a", "ך", output);
    output = find_and_replace_all("%d7%9d", "ם", output);
    output = find_and_replace_all("%d7%9f", "ן", output);
    output = find_and_replace_all("%d7%a3", "ף", output);
    output = find_and_replace_all("%d7%a5", "ץ", output);
    output = find_and_replace_all("%b4", "´", output);
    output = find_and_replace_all("%c2", "´", output);
    output = find_and_replace_all("%2d", "-", output);
    output = find_and_replace_all("%2e", ".", output);
    output = find_and_replace_all("+", " ", output); 
	
	return output;

}
function showHideLogin()
{
	if (document.getElementById("loginBox").style.display == "none")
	{
		document.getElementById("loginBox").style.display = "inline";
	}
	else
	{
		document.getElementById("loginBox").style.display = "none";
	}
}

function openHot(isGroup)
{
    if (parent.document.getElementById("grayLayer") != null && parent.document.getElementById("grayLayerPopup") != null)
    {
        if (parent.document.getElementById("grayLayer").style.display != "inline" && parent.document.getElementById("grayLayerPopup").style.display != "inline")
        {
	        parent.scrollTo(0, 0);
	        parent.document.getElementById("grayLayerHot").style.height = document.body.scrollHeight + "px";
	        parent.document.getElementById("grayLayerHot").style.width = document.body.scrollWidth + "px";
	        if(isGroup == true)
	            parent.document.getElementById("loginFrameHot").src = "../hot.asp";
	        else
	            parent.document.getElementById("loginFrameHot").src = "hot.asp";
	        parent.document.getElementById("grayLayerHot").style.display = "inline";
        }
    }
}

function openContactPage(sPos)
{
    scrollTo(0, 0);
        
    document.getElementById("grayLayer").style.height = document.body.scrollHeight + "px";
    document.getElementById("grayLayer").style.width = document.body.scrollWidth + "px";
    
    document.getElementById("loginFrame").src = "contact.asp?isMainPage=0&sPos=" + sPos;
    document.getElementById("grayLayer").style.display = "inline";
    document.getElementById("loginBox").style.display = "none";
}

function openCoffeePage(sPos, isGroupPage)
{
    scrollTo(0, 0);
        
    if(document.getElementById("grayLayer") != null)
    {
        document.getElementById("grayLayer").style.height = document.body.scrollHeight + "px";
        document.getElementById("grayLayer").style.width = document.body.scrollWidth + "px";
        
        if(isGroupPage)
            document.getElementById("loginFrame").src = "../coffee.asp?isMainPage=0&sPos=" + sPos;
        else
            document.getElementById("loginFrame").src = "coffee.asp?isMainPage=0&sPos=" + sPos;
        document.getElementById("grayLayer").style.display = "inline";
        document.getElementById("loginBox").style.display = "none";
    }
    else
    {
        if(parent.document.getElementById("grayLayer") != null)
        {
            parent.document.getElementById("grayLayer").style.height = parent.document.body.scrollHeight + "px";
            parent.document.getElementById("grayLayer").style.width = parent.document.body.scrollWidth + "px";
            
            if(isGroupPage)
                parent.document.getElementById("loginFrame").src = "../coffee.asp?isMainPage=0&sPos=" + sPos;
            else
                parent.document.getElementById("loginFrame").src = "coffee.asp?isMainPage=0&sPos=" + sPos;
            parent.document.getElementById("grayLayer").style.display = "inline";
            parent.document.getElementById("loginBox").style.display = "none";
        }
    }
}

function openGroupHot()
{
    scrollTo(0, 0);
        
    document.getElementById("grayLayer").style.height = document.body.scrollHeight + "px";
    document.getElementById("grayLayer").style.width = document.body.scrollWidth + "px";
    
    document.getElementById("loginFrame").src = "../hot.asp";
    document.getElementById("grayLayer").style.display = "inline";
}

function openLogin(comefrom, source, showMess, sPos)
{
    //LIMOR:to cancel the content page
    if(source == "new")
        return;
        
        
    mecRandomUrl = "mechrazrandom.asp?fullname=&mail=&cell=&areaid=&cityid=&comefrom=content-new&com=&logrequestids=&uid=12345";
    if(showMess == true)
        mecRandomUrl += "&showMess=true";
    mecRandomUrl += "&sPos=" + sPos;
    
    try{
        parent.scrollTo(0, 0);
    }catch (ex){}
    scrollTo(0, 0);
        
    if(document.getElementById("grayLayer") != null)
    {
        document.getElementById("grayLayer").style.height = document.body.scrollHeight + "px";
        document.getElementById("grayLayer").style.width = document.body.scrollWidth + "px";
        
        if(source == "new")
        {
            document.getElementById("loginFrame").src = mecRandomUrl;
        }
        else
        {
	        document.getElementById("loginFrame").src = "login.asp?comefrom=" + comefrom + "&source=" + source;   
	    }
	    document.getElementById("grayLayer").style.display = "inline";
        document.getElementById("loginBox").style.display = "none";
    }
    else if(parent.document.getElementById("grayLayer") != null)
    {
        parent.document.getElementById("grayLayer").style.height = parent.document.body.scrollHeight + "px";
        parent.document.getElementById("grayLayer").style.width = parent.document.body.scrollWidth + "px";
        if(source == "new")
        {
            parent.document.getElementById("loginFrame").src = mecRandomUrl;
        }
        else
        {
            parent.document.getElementById("loginFrame").src = "login.asp?comefrom=" + comefrom + "&source=" + source;
        }
        parent.document.getElementById("grayLayer").style.display = "inline";
        parent.document.getElementById("loginBox").style.display = "none";
    }
}
function openGroupContentPage(comefrom, userType, showMess, sPos, comeFromSource)
{	    
    
    mecRandomUrl = "../mechrazrandom.asp?fullname=&mail=&cell=&areaid=&cityid=&comefrom=content-new&com=&logrequestids=&uid=12345";
    if(showMess == true)
        mecRandomUrl += "&showMess=true";
    mecRandomUrl += "&sPos=" + sPos;
    
    if(comeFromSource + "" == "undefined" || comeFromSource == "") comeFromSource = "group";
    
    if(document.getElementById("grayLayer") != null)
    {
        scrollTo(0, 0);
        document.getElementById("grayLayer").style.height = document.body.scrollHeight + "px";
        document.getElementById("grayLayer").style.width = document.body.scrollWidth + "px";
        if(userType == "new")
	        document.getElementById("loginFrame").src = mecRandomUrl;
	    else
	        document.getElementById("loginFrame").src = "../login.asp?comefrom=" + comefrom + "&source=" + comeFromSource;
        document.getElementById("grayLayer").style.display = "inline";
    }
    else if(parent.document.getElementById("grayLayer") != null)
    {
        parent.scrollTo(0, 0);
        parent.document.getElementById("grayLayer").style.height = parent.document.body.scrollHeight + "px";
        parent.document.getElementById("grayLayer").style.width = parent.document.body.scrollWidth + "px";
        if(userType == "new")
	        parent.document.getElementById("loginFrame").src = mecRandomUrl;
	    else
	        parent.document.getElementById("loginFrame").src = "../login.asp?comefrom=" + comefrom + "&source=" + comeFromSource;
        parent.document.getElementById("grayLayer").style.display = "inline";
    }
}
function openPageInFrame(url, sPos)
{	    
    scrollTo(0, 0);
    url += "&sPos=" + sPos;
    
    if(document.getElementById("grayLayer") != null)
    {
        document.getElementById("grayLayer").style.height = document.body.scrollHeight + "px";
        document.getElementById("grayLayer").style.width = document.body.scrollWidth + "px";
        document.getElementById("loginFrame").src = url;	    
        document.getElementById("grayLayer").style.display = "inline";
    }
}

function openLoginAuto(comefrom)
{
	    scrollTo(0, 0);
	    document.getElementById("grayLayer").style.height = document.body.scrollHeight + "px";
	    document.getElementById("grayLayer").style.width = document.body.scrollWidth + "px";
	    document.getElementById("loginFrame").src = "loginautomain.asp?comefrom=" + comefrom;
	    document.getElementById("grayLayer").style.display = "inline";
	    document.getElementById("loginBox").style.display = "none";
}


function closeLogin2()
{
	parent.document.getElementById("grayLayer").style.display = "none";
}

function closeHot()
{
	parent.document.getElementById("grayLayerHot").style.display = "none";
	parent.location.reload();
}


function openMechrazPopup()
{
	if (parent.document.getElementById("grayLayer").style.display != "inline" && parent.document.getElementById("grayLayerHot").style.display != "inline")
	{
		parent.scrollTo(0, 0);
		parent.document.getElementById("grayLayerPopup").style.height = document.body.scrollHeight + "px";
		parent.document.getElementById("grayLayerPopup").style.width = document.body.scrollWidth + "px";
		parent.document.getElementById("mechrazimPopupFrame").src = "mechrazimPopup.asp";
		parent.document.getElementById("grayLayerPopup").style.display = "inline";
	}
}


function closeMechrazPopup()
{
	parent.document.getElementById("grayLayerPopup").style.display = "none";
	parent.location.reload();
}


function openMechrazWin(buisId, buisMail, hasExternalCode)
{
	try
	{
		window.scrollTo(0, 0);
		document.getElementById("grayLayerMechraz").style.height = document.body.scrollHeight + "px";
		document.getElementById("grayLayerMechraz").style.width = document.body.scrollWidth + "px";
		document.getElementById("mechrazFrame").src = "mechrazform.asp?buisid=" + buisId + "&buismail=" + buisMail + "&mechrazcode=" + hasExternalCode;
		document.getElementById("grayLayerMechraz").style.display = "inline";
	}
	catch(ex)
	{
		parent.window.scrollTo(0, 0);
		parent.document.getElementById("grayLayerMechraz").style.height = document.body.scrollHeight + "px";
		parent.document.getElementById("grayLayerMechraz").style.width = document.body.scrollWidth + "px";
		parent.document.getElementById("mechrazFrame").src = "mechrazform.asp?buisid=" + buisId + "&buismail=" + buisMail + "&mechrazcode=" + hasExternalCode;
		parent.document.getElementById("grayLayerMechraz").style.display = "inline";
	}
}


function closeMechrazWin()
{
    try
    {
	    parent.document.getElementById("grayLayerMechraz").style.display = "none";
	}
	catch(ex) { }
	
	try
    {
	    parent.document.getElementById("grayLayer").style.display = "none";
	}
	catch(ex) { }
}


function validatelogin()
{
	validated=true;

	if ((validated==true) && (document.login._Username.value=="")) {alert ('יש למלא דואר אלקטרוני'); document.login._Username.focus(); validated=false;}
	//if ((validated==true) && (document.login._Password.value)=="") {alert ('יש למלא סיסמה'); document.login._Password.focus(); validated=false;}

	if (validated)
	{
		document.login.loginAct.value = "go";
		document.login.submit();
	}
		
}


function isMail(val)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(val);
}


function isZehut(val)
{
	if ((isNaN(val)) || (val.indexOf(" ") > -1) || (val.length != 9))
	{
		return false;
	}
	
	return true;
}


function isCurrency(val)
{
	var str = "1234567890,-/\.";
	var chr="";

	for (i=0; i<=val.length; i++)
	{
		chr = val.substring(i, i+1);

		if (str.indexOf(chr)==-1)
		{
			return false;
	    }
    }

	return true;
}


function isNumber(val)
{
	var str = "1234567890";
	var chr="";

    if (val != "")
    {
	    for (i=0; i<=val.length; i++)
	    {
		    chr = val.substring(i, i+1);

		    if (str.indexOf(chr)==-1)
		    {
			    return false;
	        }
        }
    }
    else
    {
        return false;
    }

	return true;
}


function isPhone(val)
{
	var str = "1234567890*#,-/\ ";
	var chr="";

	for (i=0; i<=val.length; i++)
	{
		chr = val.substring(i, i+1);

		if (str.indexOf(chr)==-1)
		{
			return false;
	    }
    }

	return true;
}

function isPhone2(val)
{
	var chrOk = "1234567890";
	newVal = val;
	newVal = find_and_replace_all(" ","",newVal);
	newVal = find_and_replace_all("-","",newVal);
	for (i=0; i<=newVal.length; i++)
	{
        chr = newVal.substring(i, i+1);
        if (chrOk.indexOf(chr) == -1)
        {
            return false;
        }
    }	
	if (newVal.length < 9 || newVal.length > 10)
	{
	    return false;
	}
	if (newVal.substring(0, 1) != "0")
	{
	    return false;
	}
	if (newVal.substring(0, 2) == "05")
	{
        //mobile
	    if (newVal.length != 10)
	    {
	        return false;
	    }
	    if (newVal.substring(0, 3) != "050" && newVal.substring(0, 3) != "052" && newVal.substring(0, 3) != "054" && newVal.substring(0, 3) != "057" )
	    {
	        return false;
	    }
	    number = newVal.substring(3);
	    	
	}
    else
    {
	    // phone
	    if (newVal.substring(0, 2) == "07")
	    {
	        //hot
	        if (newVal.length != 10)
	        {
	            return false;
	        }
	        if (newVal.substring(0, 3) != "072" && newVal.substring(0, 3) != "077" )
	        {
	            return false;
	        }
	        number = newVal.substring(3);	        
	    }
	    else
	    {
	        //bezeq
	        if (newVal.length != 9)
	        {
	            return false;
	        }
	        if (newVal.substring(0, 2) != "02" && newVal.substring(0, 2) != "03" && newVal.substring(0, 2) != "04" && newVal.substring(0, 2) != "08" && newVal.substring(0, 2) != "09" )
	        {
	            return false;
	        }
	        number = newVal.substring(2);	        
	    
	    }
    }	

    if (number.substring(0, 1) == "0" || number.substring(0, 1) == "1")
    {
        return false;
    }
    if (number == "2222222" || number == "3333333" || number == "4444444" || number == "5555555" || number == "6666666" || number == "7777777" || number == "8888888" || number == "9999999")
    {
        return false;
    }	
	
    return true;

}

function forgotPassword()
{
	validated=true;

	if (document.login.username.value=="") {alert ('נא למלא שם משתמש'); document.login.username.focus(); validated=false;}
	if (validated)
		{
			ForgotAjax(document.login.username.value);
		}

}


function addtofavorites()
{
	var url="http://www.dstudent.co.il";
	var title="Dprice - כל המבצעים וההנחות באתר אחד";

	if(document.all)
	window.external.AddFavorite(url,title)
}

function addGrouTopfavorites()
{
	var url="http://www.dstudent.co.il/group";
	var title="Dprice כל הקניות החברתיות של ישראל באתר אחד";

	if(document.all)
	window.external.AddFavorite(url,title)
}


function validate_search1(object)
{
	if (object.SearchKeyword.value=="") 
	{
		alert ('יש להכניס מילת חיפוש');
		object.SearchKeyword.focus();
		return false;
	}

	if (object.SearchKeyword.value.length<3) 
	{
		alert ('יש להכניס לפחות 3 תווים במילת חיפוש');
		object.SearchKeyword.focus();
		return false;
	}

return true;
}


function ForgotAjax(username)
{
    // get transfer object
    var xmlhttp = getTransferObjectFORLOGIN();
    if(!xmlhttp){
        // Check for XMLHttpRequest
        throw "Download the newer Firefox or upgrade your browser please.";
        return false;
    }


	  TheUrl='XMLhttp_forgot_password.asp?username='+username;

	  xmlhttp.open("POST",TheUrl ,true);

	  xmlhttp.onreadystatechange=function() {
          if (xmlhttp.readyState==4) {

				answer = xmlhttp.responseText;		
				
				if (answer=="none")
				{
					alert('שם משתמש זה אינו קיים במערכת'); 
				}
				else
				{
					alert('הסיסמא נשלחה לכתובת הדואר האלקטרוני שהוכנסה בהרשמה'); 
				}

		}


		}
  xmlhttp.send(null)
} 


function find_and_replace_all(string_to_find, string_to_place, original_string)
{
    if(original_string == null)
        return "";
    if(string_to_find == null)
        return original_string;
        
	var arr = original_string.split(string_to_find);

	if ( arr.length >= 2 )
	{
		var return_string = arr[0];
		for (var i = 1 ; i < arr.length ; i++)
		{
			return_string = return_string + string_to_place + arr[i];
		}
		return return_string;	
	}
	// The string_to_find was not found - return the original string
	else	
		return original_string;
}


function CuponFavorites(cuponID)
{
	window.open ('addtofavorites.asp?cid='+cuponID, '' , 'top=10,left=10,width=400,height=150');
}


function CuponFavoritesRemove(cuponID)
{
	window.open ('addtofavorites.asp?act=remove&cid='+cuponID, '' , 'top=10,left=10,width=300,height=50');
}

function sendMechrazRequest(mecId)
{
    var ok = true;
	
    if (advForm.Fname.value == "")
    {
        ok = false;
        alert("שם מלא לא הוזן");
        return false;
    }
    if ( (advForm.preCell.selectedIndex == 0) || (advForm.preCell.selectedIndex == -1) )
    {
        ok = false;
        alert("לא הוזנה קידומת של טלפון");
        return false;
    }
	
    if (advForm.cell.value == "")
    {
        ok = false;
        alert("טלפון לא הוזן");
        return false;
    }
    else if ( (isPhone(advForm.cell.value) == false) || (advForm.cell.value.length < 7) )
    {
        ok = false;
        alert("טלפון לא תקין");
        return false;
    }
	
    if ( advForm.areaCity.selectedIndex == -1 || advForm.areaCity.selectedIndex == 0 )
    {
        ok = false;
        alert("לא הוזן אזור מגורים");
        return false;
    }
	    
    if (ok)
    {
        document.advForm.advAction.value = 'sendMec';
        document.advForm.mecId.value = mecId;
        
        document.advForm.submit();
    }
}
function openCloseCoupon(catId, cid, buisId, couponMaslul, externalUrl, userType, sPos)
{
	addStatic(cid, "clicks", buisId);

	    if(document.getElementById("trCoupon" + cid).style.display == "none")
        {
            document.getElementById("trCoupon" + cid).style.display = "";
            if(document.getElementById("trCoupon" + cid + "topLine") != null)
            {
                document.getElementById("trCoupon" + cid + "topLine").style.display = "";
                document.getElementById("couponBtn" + cid).src = "images/newDesign/closeDiscount.gif";
            }
            else
            {
                document.getElementById("trCouponTopLine").style.display = "";
                document.getElementById("couponBtn").src = "../images/newDesign/productCloseMivza.gif";
            }
            
            
            IsPageShown = Get_Cookie("IsPageShown");
	        IsPageShown = find_and_replace_all("//", "", IsPageShown);
	        if((!isNaN (IsPageShown) && (IsPageShown*1 != 1 && (IsPageShown-1) % 3 == 0)))
	            openLogin ("content-new", "new", false, sPos);
	        
            setCookie("IsPageShown", IsPageShown*1+1, 1000);
        }
        else
        {
            document.getElementById("trCoupon" + cid).style.display = "none";
            if(document.getElementById("trCoupon" + cid + "topLine") != null)
            {
                document.getElementById("trCoupon" + cid + "topLine").style.display = "none";
                document.getElementById("couponBtn" + cid).src = "images/newDesign/seeDiscount.gif";
            }
            else
            {
                document.getElementById("trCouponTopLine").style.display = "none";
                document.getElementById("couponBtn").src = "../images/newDesign/productOpenMivza.gif";
            }
        }
    
    init();
}

function openCloseProductMizva()
{
	if(document.getElementById("trCoupon") != null)
    {
        if(document.getElementById("trCoupon").style.display == "none")
        {
            document.getElementById("trCoupon").style.display = "inline";
            document.getElementById("trCouponTopLine").style.display = "inline";
            document.getElementById("couponBtn").src = "../images/newDesign/productCloseMivza.gif";
            
            IsPageShown = Get_Cookie("IsPageShown");
	        IsPageShown = find_and_replace_all("//", "", IsPageShown);
	        if((!isNaN (IsPageShown) && (IsPageShown*1 != 1 && (IsPageShown-1) % 3 == 0)))
	            openLogin ("content-new", "new", false, 0);
	        
            setCookie("IsPageShown", IsPageShown*1+1, 1000);
        }
        else
        {
            document.getElementById("trCoupon").style.display = "none";
            document.getElementById("trCouponTopLine").style.display = "none";
            document.getElementById("couponBtn").src = "../images/newDesign/productOpenMivza.gif";
        }
    }
}

function openAdvGray(comefrom, frameSrc)
{
    scrollTo(0, 0);
    var unq = new Date();
		
    if(document.getElementById("grayLayerAdv") != null)
    {
        document.getElementById("grayLayerAdv").style.height = document.body.scrollHeight + "px";
        document.getElementById("grayLayerAdv").style.width = document.body.scrollWidth + "px";
        document.getElementById("advFrame").src = frameSrc + "&unq=" + unq.getMilliseconds();
        document.getElementById("grayLayerAdv").style.display = "inline";
    }
    else if(parent.document.getElementById("grayLayerAdv") != null)
    {
        parent.document.getElementById("grayLayerAdv").style.height = parent.document.body.scrollHeight + "px";
        parent.document.getElementById("grayLayerAdv").style.width = parent.document.body.scrollWidth + "px";
        parent.document.getElementById("advFrame").src = frameSrc + "&unq=" + unq.getMilliseconds();
        parent.document.getElementById("grayLayerAdv").style.display = "inline";
    }
    else if(parent.document.getElementById("grayLayer") != null)
    {
        parent.document.getElementById("grayLayer").style.height = parent.document.body.scrollHeight + "px";
        parent.document.getElementById("grayLayer").style.width = parent.document.body.scrollWidth + "px";
        parent.document.getElementById("advFrame").src = frameSrc + "&unq=" + unq.getMilliseconds();
        parent.document.getElementById("grayLayer").style.display = "inline";
    }
}
function closeLogin(closeUrl, userType, showMess, sPos)
{
    setCookie("popupLoginPage", false, 1);
    if(parent.document.getElementById("grayLayerAdv") != null)
	{
	    if(closeUrl == "" || closeUrl == "undefined")
	    {
    	    parent.document.getElementById("grayLayerAdv").style.display = "none";
	        parent.init();
	    }
	    else
	    {
    	    location.href=closeUrl;
	    }
	}
    else if(parent.document.getElementById("grayLayer") != null)
    {
	    if(closeUrl == "" || closeUrl == "undefined")
	    {
    	    parent.document.getElementById("grayLayer").style.display = "none";
    	    parent.document.getElementById("loginFrame").src = "";
    	    if(userType != "new")
    	        parent.location.reload();
    	    else if(!isNaN(sPos))
	                parent.scrollTo(0, sPos);
    	        	    
    	    if(showMess == "true")
	            alert("'על מנת לראות את המבצע עליך ללחוץ שוב על 'צפה בהנחה");
	    }
	    else
	    {
	        if(userType == "new")
	        {
	            parent.document.getElementById("grayLayer").style.display = "none";
	            parent.document.getElementById("loginFrame").src = "";
	            
	            if(showMess == "true")
	                alert("'על מנת לראות את המבצע עליך ללחוץ שוב על 'צפה בהנחה");
	            
	            if(!isNaN(sPos))
	                parent.scrollTo(0, sPos);
	        }
	        else
    	    {
    	        location.href=closeUrl;
    	    }
	    }
	}	
}
function setBuisFrameHeight(newHeight)
{	
    if((newHeight + "").indexOf("px") == -1)newHeight = newHeight + "px";
    if(parent.document.getElementById("advFrame") != null)
    {
    	parent.document.getElementById("advFrame").style.height = newHeight;
    	newHeight = newHeight * 1 + 70;
    	if(parent.document.getElementById("grayLayerAdv") != null)
    	{
    	    if(parent.document.getElementById("grayLayerAdv").style.height <= newHeight)
    	        parent.document.getElementById("grayLayerAdv").style.height = newHeight;
    	}  
    	if(parent.document.getElementById("grayLayer") != null)
    	{
    	    if(parent.document.getElementById("grayLayer").style.height <= newHeight)
    	        parent.document.getElementById("grayLayer").style.height = newHeight;
    	}   
    	parent.init();
    }
}
function openFeedback(isGroup)
{
    scrollTo(0, 0);
        
    document.getElementById("grayLayer").style.height = document.body.scrollHeight + "px";
    document.getElementById("grayLayer").style.width = document.body.scrollWidth + "px";
    document.getElementById("grayLayer").style.display = "inline";
    document.getElementById("loginFrame").style.width = "505"; //document.body.scrollWidth; // * 1 + 10;
    //document.getElementById("loginFrame").scrolling = "no";
    if(isGroup)
        document.getElementById("loginFrame").src = "../giveFeedback.asp";
    else
        document.getElementById("loginFrame").src = "giveFeedback.asp";
}

function openCloseBottomStrip()
{
    if(document.getElementById("bottomStrip") != null)
    {
        if(document.getElementById("bottomStrip").style.display == "inline")
        {
            document.getElementById("bottomStrip").style.display = "none";
            document.getElementById("bottomStripFrm").src = "";
        }
        else
        {
            document.getElementById("bottomStrip").style.display = "inline";
            document.getElementById("bottomStripFrm").src = "bottomStrip.asp";
        }
    }
    else if(parent.document.getElementById("bottomStrip") != null)
    {
        setCookie("ShowBottomStrip", false, 1000);
        
        if(parent.document.getElementById("bottomStrip").style.display == "inline")
        {
            parent.document.getElementById("bottomStrip").style.display = "none";
            parent.document.getElementById("bottomStripFrm").src = "";
        }
        else
        {
            parent.document.getElementById("bottomStrip").style.display = "inline";
            parent.document.getElementById("bottomStripFrm").src = "bottomStrip.asp";
        }
    }
}
function openCloseBuis(buisId, buisMaslul, sivugId, userType, sPos)
{
	var frameUrl;
	var pic = new Image();
	
	if (document.getElementById("trCoupons"+buisId).style.display == "none")
	{
		var unq = new Date();
		
		var mode = "";
		
		if (window.location.toString().indexOf("buisdetails2.asp") > -1)
		{
			mode = "&mode=a";
		}
		
		pic.src = "images/btnClose2.gif";
		
		//if(userType == "new")
		//    pageName = "couponslist_New.asp";
		//else
		    pageName = "couponslist.asp";
		
		
		frameUrl = pageName + "?bid=" + buisId + "&siv=" + sivugId + mode + "&unq=" + unq.getMilliseconds();
		
		if (document.getElementById("frameCoupons"+buisId).src == "")
		{
			document.getElementById("frameCoupons"+buisId).src = frameUrl;
		}
		
		addStatic(0, "buisClicks", buisId);
		document.getElementById("trCoupons"+buisId).style.display = "inline";
		document.getElementById("buisBtn"+buisId).src = "images/btnClose2.gif";
		
		IsPageShown = Get_Cookie("IsPageShown");
		IsPageShown = find_and_replace_all("//", "", IsPageShown);
		
		//alert(IsPageShown);
		//if(userType == "new" || IsPageShown  == "False//" || IsPageShown  == "False" || IsPageShown  == "false")
		if(userType == "new" || (!isNaN (IsPageShown) && (IsPageShown*1 != 1 && (IsPageShown-1) % 3 == 0)))
		    openLogin ("content-new", "new", false, sPos);
		    
		setCookie("IsPageShown", IsPageShown*1+1, 1000);
	}
	else
	{
		document.getElementById("trCoupons"+buisId).style.display = "none";
		
		if ((window.location.toString().indexOf("buisdetails2.asp") > -1) || (window.location.toString().indexOf("product.asp") > -1))
		{
			document.getElementById("buisBtn"+buisId).src = "images/btnContinue4Blink.gif";
		}
		else
		{
			document.getElementById("buisBtn"+buisId).src = "images/btnContinue4.gif";
		}
	}
}


function openCloseBuisNew(buisId, buisMaslul, sivugId, btnType)
{
	var frameUrl;
	var pic = new Image();
	
	if (document.getElementById("trCoupons"+buisId).style.display == "none")
	{
		var unq = new Date();
		var mode = "";
		
		if (window.location.toString().indexOf("buisdetails2.asp") > -1)
		{
			mode = "&mode=a";
		}
		
		pic.src = "images/btnCouponsHide" + btnType + ".gif";
		
		document.getElementById("buisParent"+buisId).style.borderBottomWidth = 0 + "px";
		
		frameUrl = "couponslistnew.asp?bid=" + buisId + "&siv=" + sivugId + "&bmaslul=" + buisMaslul + mode + "&unq=" + unq.getMilliseconds();
		
		if (document.getElementById("frameCoupons"+buisId).src == "")
		{
			document.getElementById("frameCoupons"+buisId).src = frameUrl;
		}
		
		addStatic(0, "buisClicks", buisId);
		document.getElementById("trCoupons"+buisId).style.display = "inline";
		document.getElementById("buisBtn"+buisId).src = "images/btnCouponsHide" + btnType + ".gif";
	}
	else
	{
		document.getElementById("trCoupons"+buisId).style.display = "none";
		
		document.getElementById("buisParent"+buisId).style.borderBottomWidth = 1 + "px";
		
//		if ((window.location.toString().indexOf("buisdetails2.asp") > -1) || (window.location.toString().indexOf("product.asp") > -1))
//		{
//			document.getElementById("buisBtn"+buisId).src = "images/btnContinue4Blink.gif";
//		}
//		else
//		{
			document.getElementById("buisBtn"+buisId).src = "images/btnCouponsShow" + btnType + ".gif";
//		}
	}
}


function sendToFriend(cid)
{
	window.open("sendtofriend.asp?cid=" + cid, "sendToFriend", "top=330,left=500,width=400,height=200,scrollbars=auto");
}


function setIframeHeight(bid, newHeight)
{
    if((newHeight + "").indexOf("px") == -1)newHeight = newHeight + "px";
			
    if(parent.document.getElementById("frameCoupons"+bid) != null)
    {
	    parent.document.getElementById("frameCoupons"+bid).style.height = newHeight;
	}
	else
	{
	    if(document.getElementById("frameCoupons"+bid) != null)
	        document.getElementById("frameCoupons"+bid).style.height = newHeight;
	}
}

function setInnerCouponIframeHeight(cid, newHeight)
{	
    if((newHeight + "").indexOf("px") == -1)newHeight = newHeight + "px";
	parent.document.getElementById("trCoupon"+cid).style.height = newHeight;
}

function setMechrazFrameHeight(newHeight)
{	
    if((newHeight + "").indexOf("px") == -1)newHeight = newHeight + "px";
	parent.document.getElementById("mechrazFrame").style.height = newHeight;
}

function setIframeHeightNP(newHeight)
{
    if((newHeight + "").indexOf("px") == -1)newHeight = newHeight + "px";
	document.getElementById("npIframe").style.height= newHeight ;
}


function showDetail(cid, buisId)
{
	if (document.getElementById("contactTr"+cid).style.display == "none")
	{
		addStatic(cid, "detailsDisplay", buisId);
		document.getElementById("contactFrame"+cid).src = "monthlidform.asp?couponid=" + cid + "&buisid=" + buisId;
		document.getElementById("contactTr"+cid).style.display = "inline";
		window.scrollTo(0,window.screen.availHeight);
	}
	else
	{
		document.getElementById("contactTr"+cid).style.display = "none";
	}
}


function openCloseRate(cid)
{
    var unq = new Date();
    
    try
    {
        if (parent.document.getElementById("grayLayerMechraz").style.display == "none")
	    {
		    parent.document.getElementById("mechrazFrame").src = "couponrate.asp?cid=" + cid + "&unq=" + unq.getMilliseconds();
		    parent.document.getElementById("grayLayerMechraz").style.display = "inline";
		    parent.window.scrollTo(0,0);
	    }
	    else
	    {
		    parent.document.getElementById("grayLayerMechraz").style.display = "none";
	    }
	}
	catch(ex)
	{
	    if (document.getElementById("grayLayerMechraz").style.display == "none")
	    {
		    document.getElementById("mechrazFrame").src = "couponrate.asp?cid=" + cid + "&unq=" + unq.getMilliseconds();
		    document.getElementById("grayLayerMechraz").style.display = "inline";
		    window.scrollTo(0,0);
	    }
	    else
	    {
		    document.getElementById("grayLayerMechraz").style.display = "none";
	    }
	}
}


function addCouponsShows(cid)
{
	var cidLen = cid.length;
	var parts = 0;
	var partsMod = 0;
	var cidPart = "";
	var firstIndex = 0;
	var lastIndex = 0;
	
	if (cidLen <= 170)
	{
		parts = 1;
	}
	else
	{
		parts = cidLen / 170;
		partsMod = cidLen % 170;
		partsMod = partsMod / 170;
		
		if (partsMod > 0)
		{
			parts = parts - partsMod;
			parts = parts + 1;
		}
	}
	
	for (i=1; i<=parts; i++)
	{
		if (parts > 1)
		{
			lastIndex = cid.indexOf(",", firstIndex + 170);
			if (lastIndex == -1)
			{
				cidPart = cid.substring(firstIndex);
			}
			else
			{
				cidPart = cid.substring(firstIndex, lastIndex);
			}
			
			if (cidPart.indexOf(",") !== 0)
			{
				cidPart = "," + cidPart;
			}
			
			if (cidPart.lastIndexOf(",") !== cidPart.length-1)
			{
				cidPart = cidPart + ",";
			}
			
			firstIndex = lastIndex + 1;
		}
		else
		{
			cidPart = cid;
		}
		
		addStatic(cidPart, "shows", null);
	}
}


function addBuisShows(buisIds)
{
	var arrIds = new Array();
	var kk;
	
	if (buisIds.indexOf(",") > -1)
	{
		arrIds = buisIds.split(",");
		
		for (kk = 0; kk <= arrIds.length - 1; kk++)
		{
			addStatic(null, "buisLineViews", arrIds[kk]);
		}
	}
	else if (buisIds != "")
	{
		addStatic(null, "buisLineViews", buisIds);
	}
}


function openCloseYoram(id)
{
	if (document.getElementById(id).style.display == 'none')
	{
		document.getElementById(id).style.display = 'inline';
	}
	else
	{
		document.getElementById(id).style.display = 'none';
	}
}


function chooseAllYoram(chkMain, strRegular)
{
	var chk = eval("frm." + strRegular);
	
	if (chk.length > 1)
	{
		for (i=0; i<=chk.length-1; i++)
		{
			chk[i].checked = chkMain.checked;
		}
	}
	else
	{
		chk.checked = chkMain.checked;
	}
}


function yoramValidation(val)
{
	var i,j,k, chkSchool;
	var countSubject = document.getElementById(val + "SubjectCount").value;
	var countTat;
	var flagSubject = false;
	var flagTat = false;
	var flagSchool = false;
	
	for (i = 0; i <= countSubject-1; i++)
	{
		if (document.getElementById(val + i + "_subject").checked)
		{
			flagSubject = true;
			
			countTat = document.getElementById(val + i + "TatCount").value
			
			if (countTat == 0)
			{
				flagTat = true;
				
				try
				{
					chkSchool = eval("frm." + val + i + "_0_schools");
					
					flagSchool = false;
					
					if (chkSchool.length > 1)
					{
						for (k = 0; k <= chkSchool.length-1; k++)
						{
							if (chkSchool[k].checked)
							{
								flagSchool = true;
							}
						}
					}
					else
					{
						if (chkSchool.checked)
						{
							flagSchool = true;
						}
					}
				
					if (flagSchool == false)
					{
						return "error-school";
					}
				}
				catch (ex) { }
			}
			else
			{
				flagTat = false;
				
				for (j = 0; j <= countTat-1; j++)
				{
					if (document.getElementById(val + i + "_tat" + j).checked)
					{
						flagTat = true;
						
						try
						{
							chkSchool = eval("frm." + val + i + "_" + j + "_schools");
							
							flagSchool = false;
							
							if (chkSchool.length > 1)
							{
								for (k = 0; k <= chkSchool.length-1; k++)
								{
									if (chkSchool[k].checked)
									{
										flagSchool = true;
									}
								}
							}
							else
							{
								if (chkSchool.checked)
								{
									flagSchool = true;
								}
							}
							
							if (flagSchool == false)
							{
								return "error-school";
							}
						}
						catch (ex) { }
					}
				}
				
				if (flagTat == false)
				{
					return "error-tat";
				}
			}
		}
	}

	if (flagSubject == false)
	{
		return "error-subject";
	}
	
	
	return "ok";
}



function yoramAreasValidation(val)
{
	try
	{
		var i;
		var ok = false;
		var len = eval("frm."+val+"Areas.length");
		
		for (i=0; i<=len-1; i++)
		{
			if (eval("frm."+val+"Areas["+i+"].checked") == true)
			{
				ok = true;
			}
		}
		
		return ok;
	}
	catch (ex)
	{
		return true;
	}
}

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function Get_Cookie(name)
{
	var output = "";
	
	var start = document.cookie.indexOf(name+"=");
	var len = start+name.length+1;
	if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
	if (start == -1) return null;
	var end = document.cookie.indexOf(";",len);
	if (end == -1) end = document.cookie.length;
	output = unescape(document.cookie.substring(len,end));
	output = output.replace("lastEnter=","");
	
	var ind = output.indexOf("/");
	var ind2 = output.lastIndexOf("/");					
	var dd = output.substring(0,ind);
	var mm = output.substring(ind+1,ind2);
	var yy = output.substring(ind2+1);
	
	output = yy + "/" + mm + "/" + dd;
	
	return output;
}

function getFontSizePX(tagSize)
{
    var tagSizePX = 0;
    if(tagSize == 1) return 8;
    if(tagSize == 2) return 10;
    if(tagSize == 3) return 12;
    if(tagSize == 4) return 14;
    if(tagSize == 5) return 15;
    if(tagSize == 6) return 16;
    if(tagSize == 7) return 17;
    
    return 24;
}
		
				
function dateAddExtention(p_Interval, p_Number)
{ 
   var thing = new String(); 
    
   //in the spirt of VB we'll make this function non-case sensitive 
   //and convert the charcters for the coder. 
   p_Interval = p_Interval.toLowerCase(); 
    
   if(isNaN(p_Number)){ 
    
	  //Only accpets numbers  
	  //throws an error so that the coder can see why he effed up    
	  throw "The second parameter must be a number. \n You passed: " + p_Number; 
	  return false; 
   } 

   p_Number = new Number(p_Number); 
   switch(p_Interval.toLowerCase()){ 
	  case "yyyy": {// year 
		 this.setFullYear(this.getFullYear() + p_Number); 
		 break; 
	  } 
	  case "q": {      // quarter 
		 this.setMonth(this.getMonth() + (p_Number*3)); 
		 break; 
	  } 
	  case "m": {      // month 
		 this.setMonth(this.getMonth() + p_Number); 
		 break; 
	  } 
	  case "y":      // day of year 
	  case "d":      // day 
	  case "w": {      // weekday 
		 this.setDate(this.getDate() + p_Number); 
		 break; 
	  } 
	  case "ww": {   // week of year 
		 this.setDate(this.getDate() + (p_Number*7)); 
		 break; 
	  } 
	  case "h": {      // hour 
		 this.setHours(this.getHours() + p_Number); 
		 break; 
	  } 
	  case "n": {      // minute 
		 this.setMinutes(this.getMinutes() + p_Number); 
		 break; 
	  } 
	  case "s": {      // second 
		 this.setSeconds(this.getSeconds() + p_Number); 
		 break; 
	  } 
	  case "ms": {      // second 
		 this.setMilliseconds(this.getMilliseconds() + p_Number); 
		 break; 
	  } 
	  default: { 
       
		 //throws an error so that the coder can see why he effed up and 
		 //a list of elegible letters. 
		 throw   "The first parameter must be a string from this list: \n" + 
			   "yyyy, q, m, y, d, w, ww, h, n, s, or ms.  You passed: " + p_Interval; 
		 return false; 
	  } 
   } 
   return this; 
}


function pageShowAllRows(pageCount)
{
	var i, strLink;
	
	for (i=16; i<=pageCount; i=i+15)
	{
		try
		{
			if (document.getElementById("pagingRow"+i).style.display == "none")
			{
				document.getElementById("pagingRow"+i).style.display = "";
				strLink = "הסתר &gt;&gt;";
			}
			else
			{
				document.getElementById("pagingRow"+i).style.display = "none";
				strLink = "הכל &gt;&gt;";
			}
			
			document.getElementById("pageLinkAll").innerHTML = strLink;
		}
		catch (ex) { }
	}
}


var followMeHeight = "";

function mechrazFollowMe()
{
	if (followMeHeight == "")
	{
		followMeHeight = parseInt(body.scrollHeight - 590);
	}
	
	/*if (parseInt(body.scrollTop) <= followMeHeight)
	{
		document.getElementById("mechrazRight").style.marginTop = body.scrollTop;
		document.getElementById("hotSide").style.marginTop = body.scrollTop;
	}*/
}


/*function openCloseRgister()
{
	if (document.getElementById("registrTR").style.display == "none")
	{
		document.getElementById("registrTR").style.display = "inline";
	}
	else
	{
		document.getElementById("registrTR").style.display = "none";
	}
}*/

function openCloseCouponUse(cid)
{
	if (document.getElementById("couponUseDiv"+cid).style.display == "none")
	{
		document.getElementById("couponUseDiv"+cid).style.display = "inline";
	}
	else
	{
		document.getElementById("couponUseDiv"+cid).style.display = "none";
	}
}

function openLoginMechrazimFromFooter(fullname, mail, phone, areaId, cityId, comeFrom)
{
    if (comeFrom != "partners")
    {
	    parent.scrollTo(0, 0);
	    parent.document.getElementById("grayLayer").style.height = parent.document.body.scrollHeight + "px";
	    parent.document.getElementById("grayLayer").style.width = parent.document.body.scrollWidth + "px";
	    parent.document.getElementById("loginFrame").src = "mechrazrandom.asp?fullname=" + fullname + "&mail=" + mail + "&cell=" + phone + "&areaid=" + areaId + "&cityid=" + cityId + "&comefrom=" + comeFrom + "&sPos=" + parent.document.body.scrollHeight + "&com=&logrequestids=&uid=12345";
	    parent.document.getElementById("grayLayer").style.display = "inline";
	}
	else
	{
	    scrollTo(0, 0);
	    document.getElementById("grayLayer").style.height = parent.document.body.scrollHeight + "px";
	    document.getElementById("loginFrame").src = "mechrazrandom.asp?fullname=" + fullname + "&mail=" + mail + "&cell=" + phone + "&areaid=" + areaId + "&cityid=" + cityId + "&comefrom=" + comeFrom + "&sPos=" + document.body.scrollHeight + "&com=&logrequestids=&uid=12345";
	    document.getElementById("grayLayer").style.display = "inline";
	}
}


function trim(val)
{
	val = val.replace(/^\s+|\s+$/g,"");
	return val;
}


function showProducts(num)
{
	var i;
	
	for (i=1; i<=num; i++)
	{
		document.getElementById("trProd"+i).style.display = "inline";
	}
	
	document.getElementById("trProdMore").style.display = "none";
}


function checkboxChecked(val, checkNum)
{
	var i;
	var count = 0;
	
	for (i=0; i<val.length; i++)
	{
		if (val[i].checked)
		{
			count++;
		}
	}
	
	if (count == 0)
	{
		return false;
	}
	else
	{
		if (checkNum == 0)
		{
			return true;
		}
		else
		{
			if (count == checkNum)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
	}
}


function addStatic(cid, fldName, buisId)
{
    return false;

    // get transfer object
    var xmlhttp = getTransferObject();
    if(!xmlhttp){
        // Check for XMLHttpRequest
        throw "Download the newer Firefox or upgrade your browser please.";
        return false;
    }

	  TheUrl='statistics.asp?cid='+cid+'&fldname='+fldName+'&buisid='+buisId;

	  xmlhttp.open("POST",TheUrl ,true);

	  xmlhttp.onreadystatechange=function() {
          if (xmlhttp.readyState==4) {
			
				answer = xmlhttp.responseText;
				//alert(answer);
		}

		}
  xmlhttp.send(null)
}


function addLinksStatic(id)
{
    return false;
    
    // get transfer object
    var xmlhttp = getTransferObject();
    if(!xmlhttp){
        // Check for XMLHttpRequest
        throw "Download the newer Firefox or upgrade your browser please.";
        return false;
    }

	  TheUrl='statisticslinks.asp?id='+id;

	  xmlhttp.open("GET",TheUrl ,true);

	  xmlhttp.onreadystatechange=function() {
          if (xmlhttp.readyState==4) {
			
				answer = xmlhttp.responseText;
				//alert (answer);
		}

		}
  xmlhttp.send(null)
} 


function isColor(val)
{
	var str = "1234567890ABCDEFabcdef";
	var chr="";

	for (i=0; i<=val.length; i++)
	{
		chr = val.substring(i, i+1);

		if (str.indexOf(chr)==-1)
		{
			return false;
	    }
    }

	return true;
}


function chooseColor(sColor, valueField, id)
{
    if ((sColor.toString().length == 6) && (isColor(sColor.toString())))
    {
        eval("frm." + valueField + ".value = '" + sColor.toString().toLowerCase() + "';");
        document.getElementById(valueField + "Div").style.backgroundColor = "#" + sColor;
        document.getElementById("colorPicker" + id).style.display = "none";
        updatePartnerCode();
    }
    else
    {
        alert("צבע לא חוקי");
    }
}

function openColorPicker(id)
{
    var i;
    
    for (i=1; i<=6; i++)
    {
        document.getElementById('colorPicker' + i).style.display='none';
    }
    
    document.getElementById('colorPicker' + id).style.display='inline';
}

function updatePartnerCode()
{
    var userCode;
    var btn;
    var userWidth = "650";
    var userHeight = "1230";
    var userAff = "0";
    var couponParams = "cid=165057";
    
    switch (frm.btnColor.value)
    {
	    case "6e0019":
		    btn = 1;
	    break;
	    case "00a9e0":
		    btn = 2;
	    break;
	    case "b6dffd":
		    btn = 3;
	    break;
	    case "244487":
		    btn = 4;
	    break;
	    case "9d7708":
		    btn = 5;
	    break;
	    case "e0e6ab":
		    btn = 6;
	    break;
	    case "4e2bba":
		    btn = 7;
	    break;
	    case "ff7f02":
		    btn = 8;
	    break;
	    case "945439":
		    btn = 9;
	    break;
	    case "efa91a":
		    btn = 10;
	    break;
	    case "e0b021":
		    btn = 11;
	    break;
	    case "8e43cf":
		    btn = 12;
	    break;
	    case "59b11f":
		    btn = 13;
	    break;
	    case "badb40":
		    btn = 14;
	    break;
	    case "febf06":
		    btn = 15;
	    break;
	    case "508aab":
		    btn = 16;
	    break;
	    case "da3485":
		    btn = 17;
	    break;
	    case "c75599":
		    btn = 18;
	    break;
	    case "be3a9f":
		    btn = 19;
	    break;
	    case "156e96":
		    btn = 20;
	    break;
	    default:
	        btn = 1;
	    break;
    }
    
    if (frm.sivug.selectedIndex != 0)
    {
        couponParams = frm.sivug.options[frm.sivug.selectedIndex].value;
    }
    
    if (frm.community.selectedIndex != 0)
    {
        couponParams = couponParams + "&com=" + frm.community.options[frm.community.selectedIndex].value;
    }
    
    if (frm.areaCity.selectedIndex != 0)
    {
        couponParams = couponParams + "&areacity=" + frm.areaCity.options[frm.areaCity.selectedIndex].value;
    }
    
    if (isNumber(frm.userHeight.value))
    {
        userHeight = frm.userHeight.value;
    }
    
    if (isNumber(frm.userWidth.value))
    {
        userWidth = frm.userWidth.value;
    }
    
    if (isNumber(frm.userAff.value))
    {
        userAff = frm.userAff.value;
    }
    
    userCode = "<!--Start Dprice Code-->\n";
    userCode = userCode + "<iframe id='dpriceFrame' src='http://www.dstudent.co.il/partners.asp?" + couponParams + "&aff=" + userAff + "&c1=" + frm.boxColor.value + "&c2=" + frm.buisColor.value + "&c3=" + btn + "&c4=" + frm.text1Color.value + "&c5=" + frm.text2Color.value + "&c6=" + frm.linkColor.value + "' noresize='noresize' frameborder='0' scrolling='auto' width='" + userWidth + "px' height='" + userHeight + "px'></iframe>\n"
    userCode = userCode + "<!--End Dprice Code-->";
    
    if (document.all)
    {
        document.getElementById("userCode").innerText = userCode;
    }
    else
    {
        document.getElementById("userCode").textContent = userCode;
    }
}

function previewCode()
{
    document.getElementById("previewDiv").innerHTML = document.getElementById("userCode").value;
}

function selectAll(theField)
{
    var tempval = eval(theField);
    
    tempval.focus();
    tempval.select();
}

function copy_clip(meintext)
{
	if (window.clipboardData) 
	{
		window.clipboardData.setData("Text", meintext);
	}
	else if (window.netscape) 
	{
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
	
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;
		
		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;
		
		trans.addDataFlavor('text/unicode');
		
		var str = new Object();
		var len = new Object();
   
		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
   
		var copytext=meintext;
   
		str.data=copytext;
   
		trans.setTransferData("text/unicode",str,copytext.length*2);
   
		var clipid=Components.interfaces.nsIClipboard;
   
		if (!clip) return false;
   
		clip.setData(trans,null,clipid.kGlobalClipboard);
	}
	
   return false;
}

// ----- HOT SIDE ------
function openItemRight(id, hotSideLink)
{
    if(hotSideLink != "")
    {
        window.open(hotSideLink, "_blank");
    }
    else
    {
	    document.getElementById("itemRight"+id).style.display = "";
	    if (document.getElementById("itemRightFrame"+id).src == "")
	    {
	        document.getElementById("itemRightFrame"+id).src = "itemRightWin.asp?id=" + id;
	    }
	}
	//closeAllItemRight(id);
}
function openGroupItemRight(id)
{
	document.getElementById("itemRight"+id).style.display = "";
	if (document.getElementById("itemRightFrame"+id).src == "")
	{
	    document.getElementById("itemRightFrame"+id).src = "../itemRightWin.asp?id=" + id;
	}
	//closeAllItemRight(id);
}
function closeItemRight(id)
{
	document.getElementById("itemRight"+id).style.display = "none";
}
/*
function closeAllItemRight(id)
{
    try
    {
        for (ir in allItemsRight)
        {
            if (allItemsRight[ir] != id)
            {
                document.getElementById("itemRight"+allItemsRight[ir]).style.display = "none";
            }
        }
	}
	catch(err) {  }
}
*/


// ----- TOP MENU  ---------------
function overMenu(id)
{
    try
    {
        if(document.getElementById("AutoComplete") != null)
            document.getElementById("AutoComplete").style.display = "none";
        document.getElementById("subMenu" + id).style.display = "inline";
    }
    catch(err) { }
}

function outMenu(id)
{
    try
    {
   	    document.getElementById("subMenu" + id).style.display = "none";
    }
    catch(err) { }
}

function overSubMenu(mainId, subId)
{
    document.getElementById("subMenu" + mainId + "_" + subId).style.backgroundColor = "#FFFFFF";
    document.getElementById("subMenu" + mainId + "_" + subId + "b").style.backgroundColor = "#FFFFFF";
    document.getElementById("subMenuLink" + mainId + "_" + subId).style.color = "black";
}

function outSubMenu(mainId, subId)
{
    document.getElementById("subMenu" + mainId + "_" + subId).style.backgroundColor = "#D71A21";
    document.getElementById("subMenu" + mainId + "_" + subId + "b").style.backgroundColor = "#D71A21";
    document.getElementById("subMenuLink" + mainId + "_" + subId).style.color = "white";
} 

// -----  FILTER ------
function openFilterMore(id)
{
    //closeAllFilterMore(id);
    try
    {
        document.getElementById("more" + id).style.display = "inline";
    }
    catch(err) { }
}

function closeFilterMore(id)
{
    try
    {
   	    document.getElementById("more" + id).style.display = "none";
    }
    catch(err) { }
} 

function openCloseFilterMore(id)
{
    try
    {
        if (document.getElementById("more" + id).style.display == "inline")
        {
            document.getElementById("more" + id).style.display = "none";
        }
        else
        {
            document.getElementById("more" + id).style.display = "inline";
        }
    }
    catch(err) { }
}

function closeAllFilterMore(id)
{
    var filterMoreNames=new Array("City");
    for (x in filterMoreNames)
    {
        if(filterMoreNames[x] != id)
        {
            closeFilterMore(filterMoreNames[x]);
        }
    }
    
}  

function getUrlParam( paramName )
{
	var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' ) ;
	var oMatch = oRegex.exec( window.top.location.search ) ;

	if ( oMatch && oMatch.length > 1 )
		return decodeURIComponent( oMatch[1] ) ;
	else
		return '' ;
}
