var obj = document.all;
var cnt = 0;
var curr_obj = 0;
var next_obj = 0;
var l = 0;
function onLoad() {
	var c = parseInt((10*Math.random())%cnt);
	setTimeout("getHash(" + c + ")",100);
}
function getHash(c) {
	if( eval(obj.item("img_" + c))){ 
		if (cnt >1) {
			if(l == 0) {
				obj.item("img_" + c).style.filter="blendTrans(duration=2)";
//				obj.item("img_" + c).style.filter="revealTrans(duration=2)";
				obj.item("img_" + c).filters.blendTrans.apply();
//				obj.item("img_" + c).filters.revealTrans.Transition=10;
				obj.item("img_" + c).style.visibility = "visible";
				obj.item("img_" + c).filters.blendTrans.play();
				l ++;
				setTimeout("getHash(" + c + ")",5000);
			}
			else
			{
				next_obj = parseInt((10*Math.random())%cnt);
				if (next_obj != c) {
					obj.item("img_" + c).style.zIndex = cnt;
					obj.item("img_" + c).style.filter="blendTrans(duration=2)";
					obj.item("img_" + c).filters.blendTrans.apply();
//					obj.item("img_" + c).filters.revealTrans.Transition=10;
					obj.item("img_" + c).style.visibility = "hidden";
					obj.item("img_" + c).filters.blendTrans.play();
					obj.item("img_" + next_obj).style.filter="blendTrans(duration=2)";
					obj.item("img_" + next_obj).filters.blendTrans.apply();
//					obj.item("img_" + c).filters.revealTrans.Transition=10;
					obj.item("img_" + next_obj).style.visibility = "visible";
					obj.item("img_" + next_obj).filters.blendTrans.play();
					if (eval (obj.SendDiv))
						obj.SendDiv.style.zIndex = obj.item("img_" + next_obj).style.zIndex + 1;
					else
						obj.OutImgDiv.style.zIndex = obj.item("img_" + next_obj).style.zIndex + 1;
					l++;
					setTimeout("getHash(" + next_obj + ")",5000);
				}
				else
					getHash(next_obj);
			}
		}
		else
			obj.item("img_0").style.visibility = "visible";
	}
	else {
		setTimeout("getHash(" + c + ")",100);
	}
}
function DialogArguments()
{
	this.parent = window;
}

function loadCategory(lngCategoryID)
{
	location.href = "content.aspx?voip=" + lngCategoryID;
}
function sendTo()
{
	var wLeft;
	var wTop
	wLeft = (window.screen.width/2) - 160;
	wTop = (window.screen.height/2) - 90;
	newWin = window.open("SendToFriend.aspx" , "newwin", "top=" + wTop + ",left=" + wLeft + ",width=320,height=180,resizable=no,scrollbars=no,toolbar=no,location=no,directories=no,menubar=no,status=no");
}

function printContent()
{
	
	var w = window.open('PrintDocument.html','name','top=5000;left=5000;height=400,width=500');
}

function openSurvey()
{
	var wLeft;
	var wTop
	wLeft = (window.screen.width/2) - 210;
	wTop = (window.screen.height/2) - 160;
	var w = window.open("Survey.aspx","","top=" + wTop + ",left=" + wLeft + ",width=420,height=320,resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no,status=no")
}

/*
	Validate a form's elements according to varius attributes.
*/
function validateForm(form, title, submit, validclass, invalidclass)
{
	var i, j, u, sum;
	var input;
	var valid;
	var sErrorMsg = "";

	if (invalidclass)
	{
		for (i=0; i<document.styleSheets(0).rules.length; i++)
			if (document.styleSheets(0).rules.item(i).selectorText.toLowerCase() == "." + invalidclass.toLowerCase())
			{
				invalidclass = document.styleSheets(0).rules.item(i).style;
				break;
			}
	}

	for (i=0; i<form.elements.length; i++)
	{
		input = form.elements[i];
		// skip input when it's not rendered (ie. parent display:none)
		if (input.offsetHeight == 0) continue;
		valid = true;

		// Validate value according to element type and validation type
		switch (input.type.toLowerCase())
		{
		case "text":
		case "password":
		case "textarea":
		case "file":
			if (!input.validation) continue;
			if (input.mandatory)
			{
				if (input.mandatory.toLowerCase() == "false" && input.value.length == 0)
					continue;
			}
			else
				continue;
			switch (input.validation.toLowerCase())
			{
			case "string":
				if (input.value.length == 0)
					valid = false;
				if (input.hebrew && !/[\u05D0-\u05EA]+/.test(input.value))
					valid = false;
				break;
			case "password":
				if (input.value.length == 0)
					valid = false;
				break;
			case "integer":
				if (!/\d+/.test(input.value))
					valid = false;
				break;
			case "email":
				if (!/^[\w\.\-]+@[\w\-]+(\.\w+)+$/.test(input.value))
					valid = false;
				break;
			case "phone":
				if (!/^\+?\d+(-\d+)*$/.test(input.value))
					valid = false;
				break;
			case "id":
				j = input.value.toString();
				input.value = j.replace(/\D/g, "");
				if (/\d+/.test(input.value))
				{
					sum = 0;
					for (j=0; j<input.value.length; j++)
					{
						u = (j % 2 ? 2 : 1) * parseInt(input.value.charAt(input.value.length - j - 1));
						sum += u > 9 ? Math.floor(u / 10) + u % 10 : u;
					}
					if (sum % 10) valid = false;
				}
				else
					valid = false;
				break;
			case "compare":
				// Check the compareInput attribute
				if (input.compareInput)
					if (input.value != form.elements[input.compareInput].value)
						valid = false;
			}

			// Validate max and min according to validation type
			if (valid == true)
			{
				switch (input.validation.toLowerCase())
				{
				case "integer":
					if (input.validmax)
						if (parseInt(input.value) > parseInt(input.validmax))
							valid = false;
					if (input.validmin)
						if (parseInt(input.value) < parseInt(input.validmin))
							valid = false;
					break;
				default:
					if (input.validmax)
						if (input.value.length > input.validmax)
							valid = false;
					if (input.validmin)
						if (input.value.length < input.validmin)
							valid = false;
				}
			}
			break;
		case "select-one":
			if (input.mandatory)
				if (input.selectedIndex == 0) valid = false;
			break;
		case "select-multiple":
			sum = 0;
			for (j=0; j<input.options.length; j++)
				if (input.options[j].selected)
					sum++;
			if ((!input.validmax) && (!input.validmin))
				if (sum == 0) valid = false;
			else
			{
				if (input.validmax)
					if (sum > input.validmax)
						valid = false;
				if (input.validmin)
					if (sum < input.validmin)
						valid = false;
			}
			break;
		case "checkbox":
			if (input.mandatory)
				if (!input.checked) valid = false;
			break;
		}

		if (!valid)
		{
			if (input.validationError)
				sErrorMsg += input.validationError + "\n";
			else
				sErrorMsg += "Error in field " + input.name + "\n";
			if (invalidclass)
			{
				if (typeof(input.originalColor) == "undefined") input.originalColor = input.style.color;
				if (typeof(input.originalBackgoundColor) == "undefined") input.originalBackgoundColor = input.style.backgroundColor;
				input.style.color = invalidclass.color;
				input.style.backgroundColor = invalidclass.backgroundColor;
			}
		}
		else
		{
			if (typeof(input.originalColor) != "undefined") input.style.color = input.originalColor;
			if (typeof(input.originalBackgoundColor) != "undefined") input.style.backgroundColor = input.originalBackgoundColor;
		}
	}
	if (sErrorMsg.length)
	{
		alert(title + "\n" + sErrorMsg);
		return false;
	}
	else
	{
		if (submit)
			form.submit();
		return true;
	}
}

//------------------------------------------------------------------
// Name      : SetSizeAndFocus
// Use       : This function resize the window and locat him in the middel.
// Parameters: None.
// Author    : Peleg Rozenberg
// Date      : 13/03/2003
//------------------------------------------------------------------
function SetSizeAndFocus()
{
	if (document.all)
	{
		var L_ScreeWidth = screen.width;
		var L_ScreeHeight = screen.height;
		var L_MainTableWidth = MainTable.offsetWidth;
		var L_MainTableHeight = MainTable.offsetHeight;
		var L_XMove = 0;
		var L_YMove = 0;
		if (L_MainTableWidth + 28 > L_ScreeWidth)
			L_MainTableWidth = L_ScreeWidth;
		else
			L_MainTableWidth = L_MainTableWidth + 28;
		if (L_MainTableHeight + 29 > L_ScreeHeight - 28)
			L_MainTableHeight = L_ScreeHeight - 28;
		else
			L_MainTableHeight = L_MainTableHeight + 29;
		if (L_MainTableWidth < L_ScreeWidth)
			L_XMove = (L_ScreeWidth - L_MainTableWidth) / 2;
		if (L_MainTableHeight + 28 < L_ScreeHeight)
			L_YMove = (L_ScreeHeight - L_MainTableHeight) / 2;
		window.moveTo(L_XMove, L_YMove);
		window.resizeTo(L_MainTableWidth, L_MainTableHeight);
		MainTable.width = "100%";
	}
	window.focus();
	return(false);
}

function openPopup(p_categoryID)
{
	var wLeft;
	var wTop
	wLeft = (window.screen.width/2) - 310;
	wTop = (window.screen.height/2) - 260;
	var w = window.open("Popup.aspx?id=" + p_categoryID,"","top=" + wTop + ",left=" + wLeft + ",width=530,height=510,resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no,status=no")
}
function openPopup_db(p_categoryID)
{
	var wLeft;
	var wTop
	wLeft = (window.screen.width/2) - 310;
	wTop = (window.screen.height/2) - 260;
	var w = window.open("Popup_db.aspx?id=" + p_categoryID,"","top=" + wTop + ",left=" + wLeft + ",width=530,height=510,resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no,status=no")
}
function openPopup_art(p_categoryID)
{
	var wLeft;
	var wTop
	wLeft = (window.screen.width/2) - 310;
	wTop = (window.screen.height/2) - 260;
	var w = window.open("Popup_art.aspx?id=" + p_categoryID,"","top=" + wTop + ",left=" + wLeft + ",width=500,height=500,resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no,status=no")
}
