﻿// JavaScript Document

var loginFrame = null;

if (window.top != window) {
	try {
		document.location.href = "noframes.html";
	} catch(e) {
	}
}

function GetQueryString(key) {
    try {
        var strqs = document.location.href.split("?")[1];
    } catch(e) { return ""; }
    // Clean hash
    if (strqs == "" || strqs == null || typeof strqs == "undefined") return "";
    if (strqs.indexOf("#")>-1) {
        strqs = strqs.substr(0,strqs.indexOf("#"));
    }
    // Break
    var QS = strqs.split("&");
    // Search
    var ret = "";
    for (var i=0;i<QS.length;i++) {
        if (QS[i].split("=")[0].toString().toLowerCase() == key.toString().toLowerCase()) {
            ret = QS[i].split("=")[1].toString();
            break;
        }
    }
    return ret;
}

function CreateTermsPopup() {
	if (ac == true) return;
	var el = document.createElement("div");
	el.className = "PopupTerms";
	el.id = "__termsPopup";
	el.innerHTML = '<table cellspacing="0" cellpadding="0" border="0"><tr><td class="Checkbox"><div><img src="/img/terms_checkbox_off.gif" onclick="TermsCheckBox(this);"></div></td><td class="Text"><div>ידוע לי כי ההשתתפות בכפוף לתקנון שנמצא לעיון במשרדי חברת יורוקום בת"א </div></td><td class="Closer">&nbsp;</td></tr></table>';
	document.body.appendChild(el);
	var b = document.getElementById("__termsPopup");
	if (window.navigator.appName.toLowerCase().indexOf("explorer")>-1) var ie=true; else var ie=false;
	if (ie) {
		b.style.left = Math.round(Math.round(document.body.scrollWidth - b.offsetWidth)/2)+"px";
		b.style.top = Math.round(Math.round(document.body.scrollHeight - b.offsetHeight)/2)+"px";
	} else {
		b.style.left = Math.round(Math.round(document.body.offsetWidth - b.offsetWidth)/2)+"px";
		b.style.top = Math.round(Math.round(document.body.offsetHeight - b.offsetHeight)/2)+"px";
	}
	// Create shade
	var sh = document.createElement("div");
	sh.className = "Grey";
	sh.innerHTML = "&nbsp;";
	sh.id = "__termsBlock";
	document.body.appendChild(sh);
	var s = document.getElementById("__termsBlock");
	s.style.top = "0px";
	s.style.left = "0px";
	s.style.width = (ie)?(document.body.scrollWidth+"px"):(document.body.offsetWidth+"px");
	s.style.height = (ie)?(document.body.scrollHeight+"px"):(document.body.offsetHeight+"px");
	s.onMouseDown = _abort;
	s.onMouseUp = _abort;
	s.onMouseMove = _abort;
	s.onClick = _abort;
	// BeatBox exception
	try {
		var bb = document.getElementById("TheBeatMachine");
		if (bb != null) {
			bb.style.display = "none";
		}
	} catch(e) {
	}
}

function _abort() {
	return false;
}

function TermsCheckBox(who) {
	//who.src = (who.src.indexOf("off")>-1)?(who.src.replace("off","on")):(who.src.replace("on","off"));
	who.src = who.src.replace("on","off");
	//loginFrame.document.getElementById("btnApprove").click();
	document.getElementById("pageLogin_btnApprove").click();
}

function CloseTermsPopup() {
	checkTermsWindow();
}

function checkTermsWindow() {
	if (document.getElementById("__termsPopup") != null) {
		document.body.removeChild(document.getElementById("__termsPopup"));
	}
	if (document.getElementById("__termsBlock") != null) {
		document.body.removeChild(document.getElementById("__termsBlock"));
	}
	try {
		var bb = document.getElementById("TheBeatMachine");
		if (bb != null) {
			bb.style.display = "block";
		}
	} catch(e) {
	}
}

/** ENTER Keypress checkup function **/
function CheckEvent13(ev,func) {
	var isIE = false;
	if (navigator.appName.indexOf("Microsoft") > -1 || navigator.appName.indexOf("IE") > -1) {
		isIE = true;
	}
	if ((isIE && event.keyCode == 13) || (!isIE && ev.which == 13)) {
		if (isIE) {
			event.cancelBubble = true;
		} else {
			ev.preventDefault();
			ev.stopPropagation();
		}
		return func();
	}
}

function ShowCellularPopup(itemNum) {
	try {
		CloseSendToFriend();
		CloseDownload();
		var p = document.getElementById("cellPop");
		p.style.left = Math.round((document.body.scrollWidth - p.offsetWidth)/2) + "px";
		p.style.top = Math.round((document.body.scrollHeight - p.offsetHeight)/2) + "px";
		document.getElementById("cellPopNumber").innerHTML = itemNum + "";
	} catch(e) {}
}

function HideCellularPopup() {
	try {
		var p = document.getElementById("cellPop");
		p.style.top = "-5000px";
	} catch(e) {}
}

var stfwin = null;

function ShowSendToFriend(itemNum) {
	if (document.getElementById("TheBeatMachine") == null) {
		try {
			CloseDownload();
			HideCellularPopup();
			var p = document.getElementById("friendPop");
			p.style.left = Math.round((document.body.scrollWidth - p.offsetWidth)/2) + "px";
			p.style.top = Math.round((document.body.scrollHeight - p.offsetHeight)/2) + "px";
			document.getElementById("sendToFriendPop").src = "/inc/SendToFriend.aspx?itmID="+itemNum+"&rnd="+Math.round(Math.random()*100000);
		} catch(e) {}
	} else {
		try {
			if (stfwin != null) try { stfwin.close(); } catch(e) {}
			stfwin = window.open("/inc/SendToFriend.aspx?itmID="+itemNum+"&rnd="+Math.round(Math.random()*100000),"SendToFriendWindow","width=293,height=187");
		} catch(e) {}
	}
}

function CloseSendToFriend() {
	if (document.getElementById("TheBeatMachine") == null) {
		try {
			var p = document.getElementById("friendPop");
			p.style.left = "0px";
			p.style.top = "-3000px";
		} catch(e) {}
	} else {
		try {
			if (stfwin != null) try { stfwin.close(); stfwin = null; } catch(e) {}
		} catch(e) {}
	}
}

function ShowDownload(itemNum) {
	try {
		CloseSendToFriend();
		HideCellularPopup();
		var p = document.getElementById("downPop");
		p.style.left = Math.round((document.body.scrollWidth - p.offsetWidth)/2) + "px";
		p.style.top = Math.round((document.body.scrollHeight - p.offsetHeight)/2) + "px";
		document.getElementById("downLinkVideo").href = "/inc/download.aspx?itmID="+itemNum+"&type=1";
		document.getElementById("downLinkAudio").href = "/inc/download.aspx?itmID="+itemNum+"&type=2";
	} catch(e) {}
}

function CloseDownload() {
	try {
		var p = document.getElementById("downPop");
		p.style.left = "0px";
		p.style.top = "-2000px";
	} catch(e) {}
}


/* Login */

	var image1 = new Image();
	image1.src = "/img/frame/login_button.gif";
	var image2 = new Image();
	image2.src = "/img/frame/login_button_over.gif";
	var cb1 = new Image();
	cb1.src = "/img/frame/lg_cb_off.gif";
	var cb2 = new Image();
	cb2.src = "/img/frame/lg_cb_on.gif";
	var isIE = false;
	if (navigator.appName.indexOf("Microsoft") > -1 || navigator.appName.indexOf("IE") > -1) 
	{
		isIE = true;
	}

	//login
	function CheckEventRightNavLogin(ev)
	{
		if ((isIE && event.keyCode == 13) || (!isIE && ev.which == 13))
		{
			if (isIE) 
			{
				event.cancelBubble = true;
			}
			else
			{
				ev.preventDefault();
				ev.stopPropagation();
			}
			return frmRightNavLogin();
			return false;
		}
	}
	
	function frmRightNavLogin()
	{
		var strUserName = document.getElementById("pageLogin_txtUsername");
		var strPassword = document.getElementById("pageLogin_txtPassword");
		
		if (strUserName.value == "")
		{
			alert("ðà ìäæéï ùí îùúîù");
			strUserName.focus();
			return false;
		}
		
		if (strPassword.value == "")
		{
			alert("ðà ìäæéï ñéñîà");
			strPassword.focus();
			return false;
		}
			 
		var btn = document.getElementById("pageLogin_btnLogin");
		
		btn.click();
		
	}	
	
	
	function logOut()
	{
		var btn = document.getElementById("pageLogin_btnLogOut");
		
		btn.click();
		return false;											
	}
	
	function notActive() {
		//CreateTermsPopup();
	}
	var ac = true;

