function daychoose(day,parent)
{
	post_data ="ajax=1&day="+day+"&parent="+parent;
	loadHTML('POST','index.php', post_data, 'daysdiv');
}

function openform(id)
{
	document.getElementById(id).style.display="none";
	//document.getElementById('priem').style.display="none";

	var iWidth=500;
	var iHeight=300;
	var iRealWidth = iWidth ? iWidth : 800 ;
	var iRealHeight = iHeight ? iHeight : screen.height - 30 ;
	var iLeft = Math.round ((screen.width-500) / 2)-23;

	scrtop=document.documentElement.scrollTop;

	document.getElementById(id).style.marginLeft= iLeft+"px";
	document.getElementById(id).style.display="block";
	if(id=="addphoto")  document.getElementById("addphoto2").style.display="none";
}

function sendform(id)
{
	if(id=="opinions")
	{
		val1=document.getElementById("opinions_name").value;
		val2=document.getElementById("opinions_text").value;
		val3=document.getElementById("opinions_email").value;
		email_check=document.getElementById("opinions_email").value;

		check_dog="";
		point="";

		if(email_check!="")
		{
			point=0;
			dog=0;
			i=0;

			emailcheck_dog=email_check.search(/@/i);
			emailcheck_point=email_check.search(/\./i);



			if(emailcheck_point>=0 & emailcheck_dog>=0)
			{
				ec=1;
			}
			else
			{
				document.getElementById("opinions_email").style.backgroundColor="#ffc0c2";
				ec=0;
			}

		}
		else ec=1;

		if(val1!="Представьтесь" & val1!="" & val2!="Сообщение" & val2!="" & val3!="" & ec==1)
		{

			//post_data ="ajax=1&send_info=1&name="+name+"&text="+text+"&email="+email;
			//loadHTML('POST','index.php', post_data, 'opinionsd');
		}
		else
		{
			if(val1=="" || val1=="Представьтесь") document.getElementById("opinions_name").style.backgroundColor="#ffc0c2";
			if(val2=="" || val2=="Ваши мысли") document.getElementById("opinions_text").style.backgroundColor="#ffc0c2";
			if(val3=="") document.getElementById("opinions_email").style.backgroundColor="#ffc0c2";

		}
	}

	if(id=="addphoto")
	{
		val1=document.getElementById("addphoto_name").value;
		val3=document.getElementById("addphoto_email").value;
		val4=document.getElementById("addphoto_file").value;
		email_check=document.getElementById("addphoto_email").value;

		check_dog="";
		point="";

		if(email_check!="")
		{
			point=0;
			dog=0;
			i=0;

			emailcheck_dog=email_check.search(/@/i);
			emailcheck_point=email_check.search(/\./i);



			if(emailcheck_point>=0 & emailcheck_dog>=0)
			{
				ec=1;
			}
			else
			{
				document.getElementById("addphoto_email").style.backgroundColor="#ffc0c2";
				ec=0;
			}

		}
		else ec=1;

		if(val1!="" & val3!="" & ec==1 & val4!="")
		{
			name = document.getElementById("addphoto_name").value;
			text = document.getElementById("addphoto_text").value;
			email = document.getElementById("addphoto_email").value;

			document.getElementById("addphotoform").submit();
		}
		else
		{
			if(val1=="") document.getElementById("addphoto_name").style.backgroundColor="#ffc0c2";
			if(val3=="") document.getElementById("addphoto_email").style.backgroundColor="#ffc0c2";
			if(val4=="") document.getElementById("addphoto_file").style.backgroundColor="#ffc0c2";
		}
	}
}

function closeform(id)
{
	document.getElementById(id).style.display="none";
}

function reloadstorefront(reloadcompanyid)
{
		if(reloadcompanyid=="no")
		{
			post_data ="ajax=1&reloadform=1";
			loadHTML('POST','index.php', post_data, 'storefrontdiv');
		}
		else
		{
			post_data ="ajax=1&reloadform=1&company="+reloadcompanyid;
			loadHTML('POST','index.php', post_data, 'storefrontdiv');
		}
}
function reloadstorefrontmain(reload_category,reload_subcategory)
{
	post_data ="ajax=1&reloadform=1&category="+reload_category+"&subcategory="+reload_subcategory;
	loadHTML('POST','index.php', post_data, 'storefrontdiv');
}

loadthemeinformation_Old=0;

function loadthemeinformation($Clicked)
{
	
		document.getElementById("themeinformation").innerHTML="";
		$Width=document.getElementById("leftbox").offsetWidth;
		document.getElementById("themeinformation").style.width=$Width-0+"px";
		if(document.getElementById(loadthemeinformation_Old)) document.getElementById(loadthemeinformation_Old).className="";

		var left = document.getElementById($Clicked).offsetLeft;
		  var top = document.getElementById($Clicked).offsetTop;
		  for (var parent = document.getElementById($Clicked).offsetParent; parent; parent = parent.offsetParent)
		  {
			left += parent.offsetLeft;
			top += parent.offsetTop;
		  }
		document.getElementById("themeinformation").style.top=top-9+"px";

		document.getElementById($Clicked).className="active";
		loadthemeinformation_Old=$Clicked;
	    $Rel=$Clicked.replace("themelink","");
		post_data ="ajax=1&themeinfo="+$Rel;
		loadHTML('POST','index.php', post_data, 'themeinformation');
	
}


function sendmail()
{
	if(document.getElementById("addcommentsubmit").disabled==false)
	{
		Name=document.getElementById("addcommentname").value;
		About=document.getElementById("addcommenttext").value;
		Email=document.getElementById("addcommentemail").value;

		Post="ajax=1&callbackname="+Name+"&callbackmessage="+About+"&callbackemail="+Email;
		loadHTML('POST','index.php', Post, 'callbackresult');
		return true;
	}
}
