// JavaScript Document

function ykGetRealX(ofWho,whoParent)
{
	// Returns the "real" X-coordinate of the top left corner of the object's bounding box
	// The function tries to take into consideration the margins of containers, which normally are not taken into
	// the account when using the conventional properties.
	who = ((typeof ofWho == "string")?(document.getElementById(ofWho)):(ofWho));
	if (typeof who == "undefined" || who == null) {
		return 0;
	} else {
		if (who.tagName.toUpperCase() == "BODY" || who.tagName.toUpperCase() == "HTML") {
			return 0;
		} else {
			var reg = /px/g;
			var marL = who.style.marginLeft;
			if (marL!="") {
				marL = parseInt(marL.replace(reg,""));
			} else {
				marL = 0;
			}
			if (whoParent)
			{
				if (whoParent===who){
					return 0;
				}
				else
				{
					return who.offsetLeft + ykGetRealX(who.offsetParent,whoParent);
				}
			}
			else
			{
				return who.offsetLeft + ykGetRealX(who.offsetParent);
			}				
		}
	}
}
function ykGetRealY(ofWho,whoParent) 
{
	// Returns the "real" Y-coordinate of the top left corner of the object's bounding box
	// The function tries to take into consideration the margins of containers, which normally are not taken into
	// the account when using the conventional properties.
	who = ((typeof ofWho == "string")?document.getElementById(ofWho):ofWho);
	if (typeof who == "undefined" || who == null) {
		return 0;
	} else {
		if (who.tagName.toUpperCase() == "BODY" || who.tagName.toUpperCase() == "HTML") {
			return 0;
		} else {
			var reg = /px/g;
			var marT = who.style.marginTop;
			if (marT!="") {
				marT = parseInt(marT.replace(reg,""));
			} else {
				marT = 0;
			}
			if (whoParent)
			{
				if (whoParent===who){
					return 0;
				}
				else
				{
					return who.offsetTop + ykGetRealY(who.offsetParent,whoParent);
				}
			}
			else
			{
				return who.offsetTop + ykGetRealY(who.offsetParent);
			}
		}
	}
}


function ykSetCookie(cname, cvalue) {
	var latedate = new Date(2099,12,12,0,0,0,0);
	var cookiestr = cname+"="+cvalue+";expires="+latedate.toGMTString();
	document.cookie = cookiestr;
}

function ykGetCookie(cname) {
	// Returns the string value of the desired cookie or boolean "false" if the cookie not found
	var temparr = document.cookie.split("; ");
	for (var i=0;i<temparr.length;i++) {
				var tempitem = temparr[i].split("=");
				if (tempitem[0] == cname) {
							return temparr[i].replace(cname+"=","");
				}
	}
	return false;
}
function ykGetURLafter(val)
{
	return window.location.href.split(val)[1];
}

function ykGetFlashBannerCookieParams()
{
	var mainStr = ykGetCookie("__utmz");
	var UTM_SOURCE = getSlicedValue("utmcsr=",mainStr);
	var UTM_CAMPAIGN = getSlicedValue("utmccn=",mainStr);
	var UTM_MEDIUM = getSlicedValue("utmcmd=",mainStr);
	var UTM_TERM = getSlicedValue("utmctr=",mainStr);
	var UTM_CONTENT = ykGetURLafter("orange.co.il");
	var res = "&utm_source="+UTM_SOURCE+"&utm_medium="+UTM_MEDIUM+"&utm_campaign="+UTM_CAMPAIGN+"&utm_term="+UTM_TERM+"&utm_content="+UTM_CONTENT;
	return res;
}

function getSlicedValue(value,bigString)
{
	if (bigString.indexOf(value)>-1)
	{
		var shortStr = bigString.split(value)[1];
		return shortStr.slice(0,shortStr.indexOf("|"));
	}
	else
		return "null";
}
function ykGetId(id)
{
	return document.getElementById(id);	
}

function ykGetTab(t,total)
{
	var num = t.id.split("#")[1];
	var name = t.id.split("#")[0];
	if (total) var sum = total; else var sum = 2;
	for (var i = 1; i <= sum; i++)
	{
		if (ykGetId(name+"#"+i) === t)
		{
			if (t.className.indexOf("t_active")==-1)
			{
				t.className += ' t_active';		
				if (t.nextSibling.tagName) //IE
				{
					t.nextSibling.className += ' sep_active_left';
					t.previousSibling.className += ' sep_active_right';
				}
				else //Mozilla	
				{
					t.nextSibling.nextSibling.className += ' sep_active_left';
					t.previousSibling.previousSibling.className += ' sep_active_right';
				}
				
			}
			if (ykGetId(t.id+"_c")) ykGetId(t.id+"_c").style.display="block";
		}	
		else
		{
			ykGetId(name+"#"+i).className=ykGetId(name+"#"+i).className.replace(" t_active","")
			if (ykGetId(name+"#"+i).nextSibling.tagName) //IE
			{
				ykGetId(name+"#"+i).nextSibling.className=ykGetId(name+"#"+i).nextSibling.className.replace(" sep_active_left","");
				ykGetId(name+"#"+i).previousSibling.className=ykGetId(name+"#"+i).previousSibling.className.replace(" sep_active_right","");
			}
			else //Mozilla	
			{
				ykGetId(name+"#"+i).nextSibling.nextSibling.className=ykGetId(name+"#"+i).nextSibling.nextSibling.className.replace(" sep_active_left","");
				ykGetId(name+"#"+i).previousSibling.previousSibling.className=ykGetId(name+"#"+i).previousSibling.previousSibling.className.replace(" sep_active_right","");
			}			
			if (ykGetId(name+"#"+i+"_c")) { ykGetId(name+"#"+i+"_c").style.display="none"; }
		}
	}
}

function ykShowUl(who)
{
	if (ykGetId("bottom_lines").style.display == "none") {
		ykGetId("bottom_lines").style.display = "block";
		who.innerHTML = "לסגירת תנאי שירות";
	}
	
	else {
		ykGetId("bottom_lines").style.display = "none";
		who.innerHTML = "לפתיחת תנאי שירות";
	}
}


