var UserLanguage, CurrentUserID, Time, ObjectsToTrim = new Array();

/*
This page was written by Effy Teva for SmartPortal.NET usage only!
Copy of this code or part of it is ILLEGAL.
If you want to use any part of this code, you MUST contact Effy Teva at effy@donkey.co.il.
Any website using parts of this code may be forced to remove it!

All rights reserved (r) to Effy Teva (2006) - SmartPortal.NET v1.0
*/

function TrimObjects()
{
    //if (navigator.userAgent.indexOf("MSIE") != -1)
      //  return;
    var Count = ObjectsToTrim.length;
    if (Count == 0)
        return;
    
    var Object = ObjectsToTrim[0];
    var Width = Object.parentNode.offsetWidth - 6;
    
    Object.style.width = Width;
    for (var i = 1; i < Count; i++)
        ObjectsToTrim[i].style.width = Width;
}

function TrimObjectsResize()
{
  //  if (navigator.userAgent.indexOf("MSIE") != -1)
//        return;
    var Count = ObjectsToTrim.length;
    if (Count == 0)
        return;
    for (var i = 0; i < Count; i++)
        ObjectsToTrim[i].style.width = 200;
    setTimeout("TrimObjectsResize2()", 1);
}

function TrimObjectsResize2()
{
    var Count = ObjectsToTrim.length;
    if (Count == 0)
        return;
    var Object = ObjectsToTrim[0];
    var Width = Object.parentNode.offsetWidth - 6;
    
    Object.style.width = Width;
    for (var i = 1; i < Count; i++)
        ObjectsToTrim[i].style.width = Width;
}

function SubmitAsForm(NameValues)
{
	var S = new Array();
	S = NameValues.split(/[&=]/);
	A = "<form name=\"ABCDEF\" method=\"post\">";
	for (var i = 0; i < S.length; i++)
		A += "<input type=\"hidden\" name=\"" + S[i] + "\" value=\"" + S[++i] + "\">";
	A += "</form>";
	document.body.innerHTML += A;
	document.forms["ABCDEF"].submit();
}

function ShowHide(ID)
{
	var Object = document.getElementById(ID);
	Object.style.display = Object.style.display == "none" ? "" : "none";
}

function ChangeDir(ID)
{
	var Object = document.getElementById(ID);
	Object.dir = Object.dir == "ltr" ? "rtl" : "ltr";
}

function setCookie(name, value, expires, path) 
{
	document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + "; path=/";
}

function getCookie(name) 
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) 
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) 
			return null;
	} 
	else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	    end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}


function AddToFavorites()
{
	window.external.AddFavorite("http://www.donkey.co.il", "donkey.co.il")
}

function SetAsHomePage()
{
    document.write ("<a id=\"HomePageVButton\" onClick=\"this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.donkey.co.il');history.go(0)\"><script>document.location=document.location</script>return to <a href='http://www.donkey.co.il'>http://www.donkey.co.il</a></a>");
    document.getElementById("HomePageVButton").click();
}

function OpenFullSizeWindow(URL)
{
	GenerateFullSizeWindow(URL);
}

function GenerateFullSizeWindow(URL)
{
	return window.open(URL, "", "resizable,fullscreen=yes");
}

function OpenSmallWindow(URL)
{
	if (URL.charAt(0) != "/")
	    GenerateSmallWindow("/" + URL);
	else
	    GenerateSmallWindow(URL);
}

function GenerateSmallWindow(URL)
{
	var Width = 350;
	var Height = 275;
	
	var xMax = 640;
	var yMax = 480;
	if (document.all)
	{
		xMax = screen.width;
		yMax = screen.height;
	}
    else if (document.layers)
	{
		xMax = window.outerWidth;
		yMax = window.outerHeight;
	}
    var xOffset = (xMax - Width) / 2;
    var yOffset = (yMax - Height) / 2;

	return window.open(URL, "SmallWindow", "width=" + Width + ",height=" + Height + ",screenX=" + xOffset + ",screenY=" + yOffset + ",top=" + yOffset + ",left=" + xOffset + ",status=no,toolbar=no,menubar=no");
}

function RepositionSmallWindow()
{
	RepositionWindow(350, 275);
}

function RepositionWindow(Width, Height)
{
	var xMax = 640;
	var yMax = 480;
	if (document.all)
	{
		xMax = screen.width;
		yMax = screen.height;
	}
    else if (document.layers)
	{
		xMax = window.outerWidth;
		yMax = window.outerHeight;
	}
    var xOffset = (xMax - Width) / 2;
    var yOffset = (yMax - Height) / 2;
    window.resizeTo(Width, Height);
    window.moveTo(xOffset, yOffset);
}

function OpenWindow(URL, Name, Width, Height, Scrollbars)
{
	window.open(URL, Name, "scrollbars=" + (Scrollbars ? "1" : "0") + ",width=" + Width + ",height=" + Height);
}

function WriteSearchForm()
{
	var S = new String(document.location).toLowerCase();
	var ToReturn = "";
	
	ToReturn += "<form id=\"MainSearchForm\" name=\"MainSearchForm\" action=\"/movies/search.aspx\" onsubmit=\"this.action=document.getElementById('MainSearchSelect').value=='Google'||document.getElementById('MainSearchSelect').value=='IMDB'?'/SinglePages/' + document.getElementById('MainSearchSelect').value + '.aspx':document.getElementById('MainSearchSelect').value+'/Search.aspx'\">";
	
	ToReturn += "<table style=\"direction:rtl;width:192px\" cellpadding=\"0\" cellspacing=\"0\">";
    ToReturn += "<tr>";
    ToReturn += "<td style=\"width:8px;height:8px;background-image:url(/images/sb_03.gif)\"></td>";
    ToReturn += "<td style=\"width:176px;height:8px;background-image:url(/images/sb_02.gif)\" colspan=\"2\"></td>";
    ToReturn += "<td style=\"width:8px;height:8px;background-image:url(/images/sb_01.gif)\"></td>";
    ToReturn += "</tr>";
    ToReturn += "<tr>";
    ToReturn += "<td style=\"width:8px;height:20px;background-image:url(/images/sb_06.gif)\"></td>";
    ToReturn += "<td colspan=\"2\" style=\"width:176px;height:20px;background-image:url(/images/sb_05.gif);padding-right:10px;padding-left:10px\">";
    ToReturn += "<input type=\"text\" class=\"text\" name=\"Keywords\" style=\"border:0;font-size:9pt;width:100%;background-color:Transparent\" ";
    if (window.Keywords)
		ToReturn += " value=\"" + Keywords + "\"";
    ToReturn += "/></td>";
    ToReturn += "<td style=\"width:8px;height:20px;background-image:url(/images/sb_04.gif)\"></td>";
    ToReturn += "</tr>";
    ToReturn += "<tr>";
    ToReturn += "<td style=\"width:8px;height:5px;background-image:url(/images/sb_09.gif)\"></td>";
    ToReturn += "<td style=\"width:176px;height:5px;background-image:url(/images/sb_08.gif)\" colspan=\"2\"></td>";
    ToReturn += "<td style=\"width:8px;height:5px;background-image:url(/images/sb_07.gif)\"></td>";
    ToReturn += "</tr>";
    ToReturn += "<tr>";
    ToReturn += "<td style=\"width:8px;height:20px;background-image:url(/images/sb_13.gif)\"></td>";
    ToReturn += "<td style=\"width:113px;height:20px;background-image:url(/images/sb_12.gif)\">";
    
    ToReturn += "<select name=\"MainSearchSelect\" id=\"MainSearchSelect\" style=\"font-size:8pt\">";
	ToReturn += "<option " + (S.indexOf("/forum/") != -1 ? "selected=\"selected\" " : "") + "value=\"/Forum\">&#x05E4;&#x05D5;&#x05E8;&#x05D5;&#x05DE;&#x05D9;&#x05DD;</option>";
	ToReturn += "<option " + (S.indexOf("/wallpapers/") != -1 ? "selected=\"selected\" " : "") + "value=\"/Wallpapers\">&#x05E8;&#x05E7;&#x05E2;&#x05D9;&#x05DD; &#x05DC;&#x05DE;&#x05D7;&#x05E9;&#x05D1;</option>";
	ToReturn += "<option " + (S.indexOf("/fonts/") != -1 ? "selected=\"selected\" " : "") + "value=\"/Fonts\">&#x05E4;&#x05D5;&#x05E0;&#x05D8;&#x05D9;&#x05DD;</option>";
	ToReturn += "<option " + (S.indexOf("/gamesreviews/") != -1 ? "selected=\"selected\" " : "") + "value=\"/GamesReviews\">&#x05E1;&#x05E7;&#x05D9;&#x05E8;&#x05D5;&#x05EA; &#x05DE;&#x05E9;&#x05D7;&#x05E7;&#x05D9;&#x05DD;</option>";
	//ToReturn += "<option " + (S.indexOf("/pictureholder/") != -1 ? "selected=\"selected\" " : "") + "value=\"PictureHolder\">&#x05EA;&#x05DE;&#x05D5;&#x05E0;&#x05D5;&#x05EA; &#x05DE;&#x05E6;&#x05D7;&#x05D9;&#x05E7;&#x05D5;&#x05EA;</option>";
	//ToReturn += "<option " + (S.indexOf("/videoholder/") != -1 ? "selected=\"selected\" " : "") + "value=\"VideoHolder\">&#x05E1;&#x05E8;&#x05D8;&#x05D5;&#x05E0;&#x05D9;&#x05DD; &#x05DE;&#x05E6;&#x05D7;&#x05D9;&#x05E7;&#x05D9;&#x05DD;</option>";
	ToReturn += "<option " + (S.indexOf("/onlinegames/") != -1 ? "selected=\"selected\" " : "") + "value=\"/OnlineGames\">&#x05DE;&#x05E9;&#x05D7;&#x05E7;&#x05D9;&#x05DD; &#x05D0;&#x05D5;&#x05E0;&#x05DC;&#x05D9;&#x05D9;&#x05DF;</option>";
	ToReturn += "<option " + (S.indexOf("/downloads/") != -1 ? "selected=\"selected\" " : "") + "value=\"/Downloads\">&#x05D4;&#x05D5;&#x05E8;&#x05D3;&#x05D5;&#x05EA;</option>";
	ToReturn += "<option " + (S.indexOf("/schoolpapers/") != -1 ? "selected=\"selected\" " : "") + "value=\"/SchoolPapers\">&#x05E2;&#x05D1;&#x05D5;&#x05D3;&#x05D5;&#x05EA; &#x05DC;&#x05D1;&#x05D9;&#x05EA; &#x05E1;&#x05E4;&#x05E8;</option>";
	ToReturn += "<option " + (S.indexOf("/guides/") != -1 ? "selected=\"selected\" " : "") + "value=\"/Guides\">&#x05DE;&#x05D3;&#x05E8;&#x05D9;&#x05DB;&#x05D9;&#x05DD;</option>";
	ToReturn += "<option " + (S.indexOf("/recipes/") != -1 ? "selected=\"selected\" " : "") + "value=\"/Recipes\">&#x05DE;&#x05EA;&#x05DB;&#x05D5;&#x05E0;&#x05D9;&#x05DD;</option>";
	//ToReturn += "<option " + (S.indexOf("/jokes/") != -1 ? "selected=\"selected\" " : "") + "value=\"/Jokes\">&#x05D1;&#x05D3;&#x05D9;&#x05D7;&#x05D5;&#x05EA;</option>";
	ToReturn += "<option " + (S.indexOf("/blogs/") != -1 ? "selected=\"selected\" " : "") + "value=\"/Blogs\">&#x05D1;&#x05DC;&#x05D5;&#x05D2;&#x05D9;&#x05DD;</option>";
	ToReturn += "<option " + (S.indexOf("/faq/") != -1 ? "selected=\"selected\" " : "") + "value=\"/FAQ\">&#x05E9;&#x05D0;&#x05DC;&#x05D5;&#x05EA; &#x05E0;&#x05E4;&#x05D5;&#x05E6;&#x05D5;&#x05EA;</option>";
	ToReturn += "<option " + (S.indexOf("/users/") != -1 ? "selected=\"selected\" " : "") + "value=\"/Users\">&#x05DE;&#x05E9;&#x05EA;&#x05DE;&#x05E9;&#x05D9;&#x05DD;</option>";
	ToReturn += "<option " + (S.indexOf("/singlepages/google.aspx") != -1 ? "selected=\"selected\" " : "") + "value=\"Google\">Google</option>";
	ToReturn += "<option " + (S.indexOf("/singlepages/imdb.aspx") != -1 ? "selected=\"selected\" " : "") + "value=\"IMDB\">IMDB</option>";
	ToReturn += "</select>";
	
    ToReturn += "</td>";
    ToReturn += "<td style=\"width:63px;height:20px;background-image:url(/images/sb_11.gif);cursor:pointer\" onclick=\"document.getElementById('MainSearchForm').onsubmit();document.getElementById('MainSearchForm').submit()\"></td>";
    ToReturn += "<td style=\"width:8px;height:20px;background-image:url(/images/sb_10.gif)\"></td>";
    ToReturn += "</tr>";
    ToReturn += "<tr>";
    ToReturn += "<td style=\"width:8px;height:7px;background-image:url(/images/sb_16.gif)\"></td>";
    ToReturn += "<td style=\"width:176px;height:7px;background-image:url(/images/sb_15.gif)\" colspan=\"2\"></td>";
    ToReturn += "<td style=\"width:8px;height:7px;background-image:url(/images/sb_14.gif)\"></td>";
    ToReturn += "</tr>";
    ToReturn += "</table>";
	
	ToReturn += "</form>";
	
	return ToReturn;
}

function DisableButtons(Object)
{
	for (var i = 0; i < Object.childNodes.length; i++)
		if (Object.childNodes[i].type == 'submit' || Object.childNodes[i].type == 'button')
			Object.childNodes[i].disabled = true;
		else
			DisableButtons(Object.childNodes[i]);
}

function InputFocus(Object)
{
	if (Object.className == "TextI")
	{
		Object.className = "Text";
		Object.value = "";
	}
}

function InputBlur(Object)
{
	if (Object.value == "")
	{
		Object.value = Object.title;
		Object.className = "TextI";
	}
}

function ClearItalicValues(Object)
{
	for (var i = 0; i < Object.childNodes.length; i++)
		if (Object.childNodes[i].className == 'TextI')
		{
			Object.childNodes[i].className = 'Text';
			Object.childNodes[i].value = '';
		}
		else
			ClearItalicValues(Object.childNodes[i]);
}

function GenerateMediaPlayer(Obj, URL, Width, Height)
{
	var Size = "";
	if (Width == null && Height == null)
		Size = " width=\"300\" height=\"40\"";
	else
	{
		if (Width != null)
			Size += " width=\"" + Width + "\"";
		if (Height != null)
			Size += " height=\"" + Height + "\"";
	}
	
	var Html = "<OBJECT ID=\"MediaPlayer\" " + Size + " CLASSID=\"CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95\" STANDBY=\"Loading Windows Media Player components...\" TYPE=\"application/x-oleobject\"><PARAM name=\"autoStart\" value=\"True\"><PARAM name=\"filename\" value=\"" + URL + "\"><EMBED TYPE=\"application/x-mplayer2\" NAME=\"MediaPlayer\" " + Size + " SRC=\"" + URL + "\"></EMBED></OBJECT>";
	Obj.innerHTML += Html;
	return;

	var lngMP70;
	try
	{
		lngMP70 = ActiveXObject("WMPlayer.OCX");
	}
	catch(E){}
	var Size = "";
	if (Width == null && Height == null)
		Size = " width=\"300\" height=\"40\"";
	else
	{
		if (Width != null)
			Size += " width=\"" + Width + "\"";
		if (Height != null)
			Size += " height=\"" + Height + "\"";
	}
	if (lngMP70 == null) //6.4
	{
		if (Obj.innerHTML.indexOf("<OBJECT id=MediaPlayer") == -1)
		{
			if (Width == null && Height == null)
				Obj.innerHTML += ("<OBJECT id=MediaPlayer CLASSID=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 standby=\"Loading Microsoft Windows Media Player components...\" TYPE=\"application/x-oleobject\"" + Size + "><PARAM NAME=\"FileName\" VALUE=\"" + URL + "\"><PARAM NAME=\"AutoStart\" VALUE=\"true\"><PARAM NAME=\"ShowControls\" VALUE=\"1\"><PARAM NAME=\"ShowDisplay\" VALUE=\"false\" /></OBJECT>");
			else
				Obj.innerHTML += ("<OBJECT id=MediaPlayer CLASSID=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 standby=\"Loading Microsoft Windows Media Player components...\" TYPE=\"application/x-oleobject\"" + Size + "><PARAM NAME=\"FileName\" VALUE=\"" + URL + "\"><PARAM NAME=\"AutoStart\" VALUE=\"true\"><PARAM NAME=\"ShowControls\" VALUE=\"1\"></OBJECT>");
		}
	}
	else
	{
		if (Obj.innerHTML.indexOf("<OBJECT id=MediaPlayer") == -1)
			Obj.innerHTML += ("<OBJECT id=MediaPlayer CLASSID=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6 standby=\"Loading Microsoft Windows Media Player components...\" TYPE=\"application/x-oleobject\"" + Size + "><PARAM NAME=\"URL\" VALUE=\"" + URL + "\"><PARAM NAME=\"AutoStart\" VALUE=\"true\"><PARAM NAME=\"ShowControls\" VALUE=\"1\"><PARAM NAME=\"uiMode\" VALUE=\"mini\"></OBJECT>");
	}
}

function SetClipboard2(Value)
{
	clipboardData.setData("TEXT", Value);
}

function SetClipboard(Value)
{
	_SetClipboard(Value);
}

function _SetClipboard(Value)
{
	if (window.clipboardData) 
		clipboardData.setData("Text", Value);
	else if (window.netscape) 
	{ 
		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 = Value;

		str.data = Value;

		trans.setTransferData("text/unicode", str, copytext.length * 2);

		var clipid = Components.interfaces.nsIClipboard;
		
		if (!clip) 
			return false;

		clip.setData(trans, null, clipid.kGlobalClipboard);
	}
	else
		return false;
	return true;
}

function CheckChildren(object)
{
	CheckChildrenInternal(object, object.checked);
}

function CheckChildrenInternal(object, Checked)
{
	var Value = object.value;
	var ChildNodes = object.parentElement.childNodes;
	for (var i = 0; i < ChildNodes.length; i++)
	{
		var ChildNode = ChildNodes[i];
		if (ChildNode.accessKey == Value)
		{
			ChildNode.checked = Checked;
			CheckChildrenInternal(ChildNode, Checked);
		}
	}
}

function PopStatistics(ID1, ID2)
{
    OpenWindow("/Stats/Stats.aspx?ID1=" + ID1 + "&ID2=" + ID2, "StatsWindow", 745, 480, true);
}