﻿function highlight(me){
	fullname=me.src
	gifindex=fullname.indexOf('.gif')
	mainname=fullname.substr(0,gifindex)
	highlightname=mainname+'-h.gif';
	me.src=highlightname;
}

function lowlight(me){
	fullname=me.src
	gifindex=fullname.indexOf('-h.gif')
	mainname=fullname.substr(0,gifindex)
	lowlightname=mainname+'.gif';
	me.src=lowlightname;
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}


function showmenu(elmnt)
{	
	document.getElementById(elmnt).style.visibility="visible"
}

function hidemenu(elmnt)
{
	document.getElementById(elmnt).style.visibility="hidden"
}

function highbg(me)
{	
	me.style.background='#ff8c53'
	me.style.color ='#b43522'
}

function lowbg(me)
{
	me.style.background='#b43522'
	me.style.color='#ffe970'
}

function openlink(newurl){
	
	newurl="http://"+document.location.host+"/resellers/"+newurl;
	hascart = (typeof(parent.cart)!='undefined')
	if (hascart) {
		cartlocation = (parent.cart.document.location.href)
		filledcart= (parent.cart.document.getElementById('carttable').rows.length>1)
	} else {
		filledcart = false
	}
	if (!filledcart){
//			if (hascart) parent.cart.document.location = 'buycart.php?order='+neworder
			parent.document.location.replace(newurl);
	} else {
		go = confirm ("سفارشات شما ارسال نشده است. آيا از ارسال سفارشات صرف نظر مي‌كنيد؟")
		if (go) {
			parent.document.location.replace(newurl);
		}
	}
}

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.toGMTString());
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf("advanced");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 ;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return ""
}