
function makecookie(Name,Value,Expiry,Path,Domain,Secure){
	if (Expiry!= null) {
		var datenow = new Date();
		datenow.setTime(datenow.getTime() + Math.round(86400000*Expiry));
		Expiry = datenow.toGMTString();
	}

	Expiry = (Expiry!= null)? '; expires='+Expiry : '';
	Path = (Path!= null)?'; path='+Path:'';
	Domain = (Domain!= null)? '; domain='+Domain : '';
	Secure = (Secure!= null)? '; secure' : '';
	document.cookie = Name + '=' + escape(Value) + Expiry + Path + Domain + Secure;
}

function readcookie(Name) {
	var cookies = document.cookie;
	if (cookies.indexOf(Name + '=') == -1) return null;
		var start = cookies.indexOf(Name + '=') + (Name.length + 1);
		var finish = cookies.substring(start,cookies.length);
		finish = (finish.indexOf(';') == -1)? cookies.length : start + finish.indexOf(';');
		return unescape(cookies.substring(start,finish));
	}

	function setActivestyleSheet(pTitle) {
		var vLoop, vLink;
		for(vLoop=0; (vLink = document.getElementsByTagName("link")[vLoop]); vLoop++) {
			if(vLink.getAttribute("rel").indexOf("style")!= -1 && vLink.getAttribute("title")) {
				vLink.disabled = true;
				if(vLink.getAttribute("title") == pTitle) vLink.disabled = false;
			}
		}
	}

	function stilsec (vSelection) {
	makecookie('style', vSelection, 90, '/');
	setActivestyleSheet(vSelection)
}

if (document.cookie.indexOf('style')!=-1) {
	css = readcookie('style');
	setActivestyleSheet(css)
}


function gocatURL(form)
{ 
	var myindex=form.gocat.selectedIndex; 
	if (!myindex=="")
	{ 
		window.location.href=form.gocat.options[myindex].value;
	}
} 

function sthe(ids, tab)
{
	var arrayids = new Array();
	var arrayids = ids.split(',');  
	var carray = (arrayids.length - 1);
	for(i=0;i<=carray;i++)
	{ 
		if(arrayids[i] == tab)
		{ 
			document.getElementById(tab).className='tab-uh-a'; 
		}else{ 
			document.getElementById(arrayids[i]).className='false'; 
		}
	}
} 

var tabhe = 's-tmain,s-tgames'; 
var trids = 't-wn'; 
var tcatids = 'div_new,div_visit,div_random,div_rate,div_send,div_comment'; 

function plimages() 
{
	var d=document; if(d.images)
	{ 
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=plimages.arguments; 
		for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0)
		{ 
			d.MM_p[j]=new Image; d.MM_p[j++].src=a[i]; 
		}
	}
}

function csearch(a, p)
{ 
	if (p.value == '')
	{ 
		alert('حدد قسم البحث');
		p.focus(); 
		return false;
	} else { 
		window.location = 'search?sec='+p.value+'&q='+a.value;
	}
}

function selsel(num)
{
	var ds = document.getElementById('selectsearch');
	ds.selectedIndex = num;
} 	

var capc = 0;
function recap()
{
	document.getElementById('cap_image').src= urlimca+'?c='+Math.random();
	document.getElementById('c_cap').value="";
	document.getElementById('c_cap').focus();
	capc++;
}

function gdata(link,inv,mode)
{
	$.get(link,function(data){$("#"+inv).html(data);}); 

	document.getElementById(inv).style.display = 'block';
}


function tabs(ids, tab)
{
	var arrayids = new Array();
	var arrayids = ids.split(','); 
	var carray = (arrayids.length - 1);
	
	for(i=0;i<=carray;i++)
	{
		if(arrayids[i] == tab)
		{
			document.getElementById(arrayids[i]).style.display="block";
			var tabb = document.getElementById('tab-b');
			document.getElementById(tab+'-s').className='selectedtab a';
		}else{
			document.getElementById(arrayids[i]).style.display="none";
			document.getElementById(arrayids[i]+'-s').className='false';
		}
	}
}

/**

$(document).ready(function(){$("#navigation").superfish({animation : {opacity:"show",height:"show"}}).find(">li:has(ul)").find("a").focus(function(){});});
*/