function DialogArguments()
{
	this.parent = window;
}

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=620,height=520,resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no,status=no")
}

function changeColor(Index)
{
	document.all.BigColorImage.src="Objects/Colors/Big_" + Index + ".jpg"
}

function changeGallery(Index)
{
	//alert(document.all["SmallDetailsImage"].length);
	var count = document.all["SmallGalleryImage"].length;
	for (i=0; i<count; i++)
	{	
		
		if (document.all["SmallGalleryImage"][i].imgId==Index)
		{
			document.all["SmallGalleryImage"][i].src="Objects/Gallery/Small_" + Index + "_over.gif"
			document.all["BottomTextContainer"][i].style.display="";
		}
		else
		{
			document.all["SmallGalleryImage"][i].src="Objects/Gallery/Small_" + document.all["SmallGalleryImage"][i].imgId + ".gif"
			document.all["BottomTextContainer"][i].style.display="none";
		}
	}
	
	document.all.BigGalleryImage.src="Objects/Gallery/Big_" + Index + ".jpg"

}

function loadCategory(lngCategoryID)
{
	location.href = "content.aspx?id=" + 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;
				}
				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;
				}
			}
			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);
	}
}
	function init()
	{
		window.onresize = prepare_recalc;
		recalc();
	}

	// Envokes recalc() in 200ms, but first cancels last envoke
	function prepare_recalc()
	{
		window.setTimeout("recalc();", 1);
	}
	
	function recalc()
	{
		if(document.all["Data"])
		{
				if (document.body.clientHeight>140)
				document.all["Data"].style.height = document.body.clientHeight-140
		}
	}


function checktav(the_string){
		for(i=0;i<=the_string.length;i++) 
		{
			 
			 tav=(the_string.toLowerCase().charAt(i));
			 if(tav=="'" ||  tav=="*" || tav=="%")
			 {
			 	alert("Invalid characters " + tav)
			 	return -1;
			 }
		}
return 0;
}
function SendS(str)
{

if (str.length<2 )
{
	alert("Please type more then one character")
	return;
	
}
check=0;
if(str!="")
{
	check=checktav(str)	
	if (check==-1)	
	{
		
		return false;
	}	
	
}
FormS.action="Search.aspx?id=68&q=" +  str;
FormS.submit();
}