function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=420,height=375,left = 100,top = 100');");
}
function popUpsubmit(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=500,left = 100,top = 100');");
}
function popUpEditor(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=850,height=1500,left = 100,top = 300');");
}
function search_clearsearch() {
	if (document.search.research.value == "Enter Keyword") { document.search.research.value = ""; }
}
function search_restoresearch() {
	if (document.search.research.value == "") { document.search.research.value = "Enter Keyword"; }
}

<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
var win=null;
function NewWindow(mypage,myname,w,h,scroll,menubar,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',menubar='+menubar+',location=no,directories=no,status=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
}
/*function show()
{
	document.getElementById('img1').style.display = '';
}
function hide()
{
	document.getElementById('img1').style.display = 'none';
}*/
var offsetfrommouse=[15,25]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.
var defaultimageheight = 40;	// maximum image size.
var defaultimagewidth = 40;	// maximum image size.
var divIdGlob;
var wdth;
var hth;
function truebody(){return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body}
function followmouse(e){
	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)
	if (typeof e != "undefined"){
		if (docwidth - e.pageX < defaultimagewidth + 2*offsetfrommouse[0]){xcoord = e.pageX - xcoord - defaultimagewidth;} else {xcoord += e.pageX;}
		if (docheight - e.pageY < defaultimageheight + 2*offsetfrommouse[1]){ycoord += e.pageY - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + e.pageY - docheight - truebody().scrollTop));} else {ycoord += e.pageY;}
	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < defaultimagewidth + 2*offsetfrommouse[0]){xcoord = event.clientX + truebody().scrollLeft - xcoord - defaultimagewidth;} else {xcoord += truebody().scrollLeft+event.clientX}
		if (docheight - event.clientY < (defaultimageheight + 2*offsetfrommouse[1])){ycoord += event.clientY + truebody().scrollTop - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + event.clientY - docheight));} else {ycoord += truebody().scrollTop + event.clientY;}
	}
	xcoord = xcoord - wdth-20;
	ycoord = ycoord - hth-25; 
	var myDiv = document.getElementById(divIdGlob);myDiv.style.left=xcoord+"px";myDiv.style.top=ycoord+"px";
}
function show(imagename,divId,e)
{
//alert('')
    divIdGlob = divId;
    var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)
	/*if( (navigator.userAgent.indexOf("Konqueror")==-1 || navigator.userAgent.indexOf("Firefox")!=-1 || (navigator.userAgent.indexOf("Opera")==-1 && navigator.appVersion.indexOf("MSIE")!=-1))&& (docwidth>650 && docheight>500)) 
	{*/

	wdth = getImgSize(imagename,"w");
	hth = getImgSize(imagename,"h");
	    
	divIdGlob = divId;
	document.onmousemove=followmouse;
	newHTML = '<div style="border: 1px solid #666666;">';
	newHTML = newHTML + '<img src="' + imagename + '" >';
	newHTML = newHTML + '</div>'; 
	var myDiv = document.getElementById(divId);
	myDiv.innerHTML = newHTML;
	myDiv.style.display="block";
		
		//alert(myDiv.innerHTML)
	//}
}

function hide(divId){
	divIdGlob = divId;var myDiv = document.getElementById(divId);myDiv.style.display = "none";document.onmousemove="";myDiv.left="-500px";
}

function getImgSize(imgSrc,whichsize)
{
	var newImg = new Image();
	newImg.src = imgSrc;
	var height = newImg.height;
	var width = newImg.width;
	if(whichsize=="w")
		return width;
	else
		return height; 
}

function saveImage(id,days) {
	id = id.replace(".","_");
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
 
	if(days == -1){
		document.cookie = id+"=0"+expires+"; path=/";
		document.cookie = "index_"+id+"=0"+expires+"; path=/";
		alert("This layouts has been removed!");
	}else{
		document.cookie = id+"=1"+expires+"; path=/";
		document.cookie = "index_"+id+"="+cookieCount()+expires+"; path=/";
		alert("This layouts has been saved!");
	}
}

function getImage(id) {
	id = id.replace(".","_");
	var nameEQ = id + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function removeImage(id) {
	id = id.replace(".","_");
	saveImage(id,-1);
	window.location = "saved.php";
}
 
// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

function cookieCount() 
{ 
	var date = new Date()

	var CookieString
	var CookieSet
	var SetSize
	var CookiePieces
	var CookieValue
	var x
	x = 0

	var iter=0;
 
	CookieString = document.cookie
	CookieSet = CookieString.split (';')
	SetSize = CookieSet.length
	CookieValue = ""
	  
	for (x = 0; ((x < SetSize) && (CookieValue == "")); x++)
	{
		CookiePieces = CookieSet[x].split ('=') 
		if (CookiePieces[0].substring (0,1) == ' ')
		{
			CookiePieces[0] =
			CookiePieces[0].substring (1, CookiePieces[0].length)
		}
		if (CookiePieces[0]!= "")
		{
			if (CookiePieces[0].substring (0,7) == 'layout_')
			{	
				iter++;
			}
		}
	}
	if(iter==0)
		return 0;
	else
		return (iter-1);
}


function removeAllImages() 
{ 
	var date = new Date()
	var CookieString
	var CookieSet
	var SetSize
	var CookiePieces
	var CookieValue
	var x
	x = 0
 
	CookieString = document.cookie
	CookieSet = CookieString.split (';')
	SetSize = CookieSet.length
	CookieValue = ""
	  
	for (x = 0; ((x < SetSize) && (CookieValue == "")); x++)
	{
		CookiePieces = CookieSet[x].split ('=') 
		if (CookiePieces[0].substring (0,1) == ' ')
		{
			CookiePieces[0] =
			CookiePieces[0].substring (1, CookiePieces[0].length)
		} 
		if (CookiePieces[0].length >=7)
		{	
			if (CookiePieces[0].substring (0,7) == 'layout_')
			{
				cookie_id = CookiePieces[0];
				cookie_id = cookie_id.replace(".","_");
	 
				date.setTime(date.getTime()+(-1*24*60*60*1000));
				expires = "; expires="+date.toGMTString();
				document.cookie = cookie_id+"=0"+expires+"; path=/";
			}
		} 
		if (CookiePieces[0]!= "")
		{
			if (CookiePieces[0].length >=13)
			{
				if (CookiePieces[0].substring (0,13) == 'index_layout_')
				{
					cookie_id = CookiePieces[0];
					cookie_id = cookie_id.replace(".","_");
		 
					date.setTime(date.getTime()+(-1*24*60*60*1000));
					expires = "; expires="+date.toGMTString();
					document.cookie = cookie_id+"=0"+expires+"; path=/";
				}
			}
		}
	}
	alert("All layouts have been removed!");
	window.location = "saved.php";

}
		