function diffuseres(divId)
{
new Effect.Fade(divId, {duration: 5});
}

/* Wall papers */

function popwp(page)
{
	var resdiv = document.getElementById('pop');
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}	
	var rand_no = Math.random();
	rand_no = rand_no * 100;
	rand_no = Math.ceil(rand_no);	
	var pars = "p="+page+"&r="+rand_no;
	var myAjax = new Ajax.Updater( 'pop', 'wp_pop.php', { method: 'get', parameters: pars});
}


/* .Wall papers */


/* Avatars */

function popav(page)
{
	var resdiv = document.getElementById('pop');
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}	
	var rand_no = Math.random();
	rand_no = rand_no * 100;
	rand_no = Math.ceil(rand_no);	
	var pars = "p="+page+"&r="+rand_no;
	var myAjax = new Ajax.Updater( 'pop', 'av_pop.php', { method: 'get', parameters: pars});
}


/* .Avatars */


/* Games */

function popg(page)
{
	var resdiv = document.getElementById('pop');
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}	
	var rand_no = Math.random();
	rand_no = rand_no * 100;
	rand_no = Math.ceil(rand_no);	
	var pars = "p="+page+"&r="+rand_no;
	var myAjax = new Ajax.Updater( 'pop', 'pg_pop.php', { method: 'get', parameters: pars});
}


/* .Games */

/* Videos */

function popvi(page)
{
	var resdiv = document.getElementById('pop');
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}	
	var rand_no = Math.random();
	rand_no = rand_no * 100;
	rand_no = Math.ceil(rand_no);	
	var pars = "p="+page+"&r="+rand_no;
	var myAjax = new Ajax.Updater( 'pop', 'vi_pop.php', { method: 'get', parameters: pars});
}

/* Comments */
function submitvicform(vi_id)
{
	if (document.vicomntform.vicname.value == "")
	{
		alert("Please enter your name");
		document.vicomntform.vicname.focus();
	}
	else if (document.vicomntform.vicomment.value == "")
	{
		alert("Please enter your Comment");
		document.vicomntform.vicomment.focus();
	}
	else 
	{
		var resdiv = document.getElementById('vicomntres');
		if (resdiv.style.display == 'none')
		{
			resdiv.style.display = 'block';
		}			
		var popdivname = "popvic";
		var popdiv = document.getElementById(popdivname);
		if (popdiv.style.display == 'none')
		{
			popdiv.style.display = 'block';
		}					
		var params = Form.serialize($('vicomntform'));
		new Ajax.Updater(resdiv, 'vicomnt_submit.php', {asynchronous:true, parameters:params,onComplete:function(){diffuseres(resdiv); emptyvicform(); dispcomnt(popdivname,vi_id)}});		
	}
}

function dispcomnt(comntdiv,vi_id)
{
	var pars = "vi_id="+vi_id;
	var url = "vi_comnt.php";
	var resdiv = document.getElementById(comntdiv);
	if (resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}
	var myAjax1 = new Ajax.Updater( resdiv, url, { method: 'get', parameters: pars});	
}


function emptyvicform()
{
	document.vicomntform.vicname.value = "";
	document.vicomntform.vicomment.value = "";
}

/* .Comments */


/* Rating */
function ratevideo(vi_id,l)
{
	var divid = document.getElementById('vir_res_div');
	divid.style.display = 'block';
	var pars = "vi_id="+vi_id+"&rate="+l;
	var url = "vir_rate.php";
	var myAjax1 = new Ajax.Updater( divid, url, { method: 'get', parameters: pars, onComplete:function(){diffuseres(divid); popvir(vi_id);} });
}

function popvir(vi_id)
{
	var rand_no = Math.random();
	rand_no = rand_no * 100;
	rand_no = Math.ceil(rand_no);		
	var pars = "vi_id="+vi_id+"&rn="+rand_no;
	var url = "vir_pop.php";
	var myAjax1 = new Ajax.Updater( 'popvir_div', url, { method: 'get', parameters: pars });
}
/* .Rating */

/* .Videos */



/* Contact Us */
function submitcform()
{
	if (document.contform.cname.value=="")
	{
		alert("Please enter your name");
		document.contform.cname.focus();
	}
	else if (document.contform.cemail.value=="")
	{
		alert("Please enter your email");
		document.contform.cemail.focus();
	}
	else
	{
		var result = checkbae('contform','cemail');
		if (result == true)
		{

			if (document.contform.contquery.value=="")
			{
				alert("Please enter your Query");
				document.contform.contquery.focus();
			}
			else
			{
				var resdiv = document.getElementById('contres');
				resdiv.style.display = 'block';
				resdiv.innerHTML = 'Please wait...';
				var params = Form.serialize($('contform'));
				new Ajax.Updater(resdiv, 'contactsubmit.php', {asynchronous:true, parameters:params,onComplete:function(){diffuseres(resdiv); emptycform();}});		
			}

		}
		else
		{
		}		
	}
}

function emptycform()
{
	document.contform.cname.value = '';	
	document.contform.cemail.value = '';
	document.contform.contquery.value = '';	
}

var testresults
function checkemail(formname,inputname){

var a="document.";
var b=".value";
var str = eval(a+formname+"."+inputname+b);
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true
else{
alert("Please enter a valid email address!")
eval(a+formname+"."+inputname+".focus()");
testresults=false
}
return (testresults)
}

function checkbae(formname,inputname){
if (document.layers||document.getElementById||document.all)
return checkemail(formname,inputname)
else
return true
}

/* .Contact Us */

