var updNWin = 0; var numNWin = 0; var updNPop = 0;
var imgload = new Image;
var thedom = "http://"+window.location.hostname;
imgload.src = thedom+"/images/loading.gif";
imgload.src = thedom+"/images/add_port.gif";
imgload.src = thedom+"/images/but_hover.png";
imgload.src = thedom+"/images/but_hovers.png";
imgload.src = thedom+"/images/bg_black2.png";

function getGlobal(){
return (function(){
return this;
}).call(null);
}

function xz(){	
}

//Event.observe( document, 'unload', Event.unloadCache );

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null ) {node = document;}
	if ( tag == null ) {tag = '*';}
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {if ( pattern.test(els[i].className) ) {classElements[j] = els[i];j++;}}
	return classElements;}
sfHover = function() {     
var sfEls = getElementsByClass("imgbg");    
for (var i=0; i<sfEls.length; i++) {         
	sfEls[i].onmouseover=function() {this.className+=" imgbgfx";}
	sfEls[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" imgbgfx\\b"), "");}}} 
if (window.attachEvent) window.attachEvent("onload", sfHover);

function submitenter(e){
	var keycode;
	if (window.event) keycode = window.event.keyCode; 
	else if (e) keycode = e.which; 
	else return false; 
	return (keycode == 13); 
}

function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	var path = window.location.hostname;
	path = "/";
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((path) ? ';path=' + path : '' ) +
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());}
	
function getCookie(c_name){
if (document.cookie.length>0)  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));    }   }
return "";}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");}

function gsearch(surl,stxt,starg){updAds();
	if (stxt!="" && stxt!="enter search term") {
		surl = surl+stxt;
		if (starg==0 || starg==""){
			location.href = surl; }
		if (starg==1){
			window.open(surl); }
		if (starg==2){
			Lightview.show({href: surl,rel: 'iframe',options: {topclose: true,fullscreen: true}}); }
	}
}

function dopage(thepage,params,resdiv,restxt,noFade) {	
	updAds();
	new Ajax.Request(thepage, {
		  method: 'post',
		  evalScripts: true,
		  parameters: params,
		  onSuccess: function (res){
			if (resdiv!=""){
				if (restxt==""){restxt=res.responseText;}
				if (noFade=="1"){updDiv(resdiv,restxt);}else{updDiv(resdiv,restxt,1);}
			}
		}
	});
}
function dopagep(thepage,params,resdiv,restxt) {updAds();
	new Ajax.Request(thepage, {
		  method: 'post',
		  evalScripts: true,
		  parameters: params,
		  onSuccess: function (res){
			if (resdiv!=""){
				if (restxt==""){restxt=res.responseText;}
				updDiv(resdiv,restxt,1);
			}
		}
	});
}

function dopageCh(deltxt,thepage,params,resdiv,restxt) {
	var answer = confirm("Are you sure you want to\npermanently Delete this "+deltxt)
	if (answer){dopage(thepage,params,resdiv,restxt);}else{return false;}
}

function removeChild(elem){
	var theelem = document.getElementById(elem);
	if (theelem.hasChildNodes()){
		while ( theelem.childNodes.length >= 1 ){
			theelem.removeChild( ctheelemell.firstChild ); } }
	theelem = null;
}

function mk_sort(thediv,elid,gid){
	Sortable.create(thediv+"L",
	{ tag: 'div',
	  handle: 'img_move',
	  dropOnEmpty: true, 
	  onUpdate:function() {		
	  		var params = elid + "|||&" + Sortable.serialize(thediv+"L");
			upd_order(thediv,params,gid);
		}
	});
}


function updorder(thediv,params) {
	new Ajax.Request(thedom+'/ajax/upd_'+ thediv +'.php', {
		  method: 'post',
		  parameters: params,
		  onSuccess: function (res){		
		    /*alert (params);	
*/		}
	});
}
function mksort(thediv){
	Sortable.create(thediv+"L",
	{ tag: 'div',
	  handle: 'img_move',
	  dropOnEmpty: true, 
	  onUpdate:function() {	
	  		var params = Sortable.serialize(thediv+"L");
			updorder(thediv,params);
		}
	});
}

function loadjsfile(filename,thediv,height,width){	
	if (filename!="") {	
		var script=document.createElement('iframe');
		script.setAttribute('src',filename);
		script.setAttribute('type','text/javascript');		
		script.setAttribute('height',height);
		script.setAttribute('width',width);
		script.setAttribute('align','center');
		script.setAttribute('frameBorder','0');
		$("section_"+thediv+"C").className='content ali_c';	
		$("section_"+thediv+"C").appendChild(script);	
		$("section_"+thediv+"C").appendChild($("google_"+thediv));	
		script = null;
}}

function add_element(thediv,thetxt) {
	new Ajax.Updater('edit_'+thediv,thedom+'/ajax/add_'+ thediv +'.php', {
		method: 'post',
		parameters: "q=" + thetxt,
		onSuccess: function (res){
			var newdiv = document.createElement("div");
			var theres = res.responseText.split("|||");
			newdiv.innerHTML = theres[1];
			newdiv.id = "item_" + theres[0];
			newdiv.className = "mg_1 bord_b2";
			$(thediv+'L').appendChild(newdiv);	
			newdiv = null;
		}
	});	
}

function edit_element(thediv,theid) {
	new Ajax.Updater('edit_'+thediv,thedom+'/ajax/edit_'+ thediv +'.php', {
		method: 'post',
		evalScripts: true,
		parameters: "id=" + theid,
		onSuccess: function (res){
			updDiv('edit_'+thediv,res.responseText);
		}
	});	
}
function ae_element(thediv,params,theid) {
	new Ajax.Request(thedom+'/ajax/ae_'+ thediv +'.php', {
		  method: 'post',
		  parameters: params,
		  onSuccess: function (res){		
			addDiv(thediv+'L',res.responseText,theid);
		}
	});
}
function del_element(thediv,theid,chk) {
	if (chk!=""){var answ = confirm("Are you sure you want to permanently \n Delete this "+chk);}
	if (answ){
	new Ajax.Request(thedom+'/ajax/del_'+ thediv +'.php', {
		  method: 'post',
		  parameters: "id=" + theid,
		  onSuccess: function (res){		
			delDiv(thediv+'L','item_'+theid);
		}
	});}
}

function edit_ele(thediv,theid,elid) {
	new Ajax.Request('../sections/home/edit_'+ thediv +'.php', {
		  method: 'post',
		  parameters: "elid=" + elid+"&id=" + theid,
		  onSuccess: function (res){	
			updDiv('edit_'+thediv,res.responseText);
			Modalbox.resizeToContent();
		}
	});
}
function ae_ele(thediv,params,theid) {
	new Ajax.Request('../sections/home/ae_'+ thediv +'.php', {
		  method: 'post',
		  parameters: params,
		  onSuccess: function (res){		
			addDiv(thediv+'L',res.responseText,theid);
			Modalbox.resizeToContent();
		}
	});
}
function del_ele(thediv,theid,elid) {
	new Ajax.Request('../sections/home/del_'+ thediv +'.php', {
		  method: 'post',
		  parameters: "elid=" + elid+"&id=" + theid,
		  onSuccess: function (res){		
			delDiv(thediv+'L','item_'+theid);
			Modalbox.resizeToContent();
		}
	});
}

function upd_order(thediv,params,gid) {
	var thefol="home";
	if (gid==1){thefol="port";}
	new Ajax.Request('../sections/'+thefol+'/upd_'+ thediv +'.php', {
		  method: 'get',
		  parameters: params
	});
}

function div_hei(thediv, newhei, overflow){
	$(thediv).style.overflow = overflow;
	$(thediv).style.height = newhei+"px";	
}

function notUpd(sect,params){
	if(updNWin==sect || sect==0){updNWin = 0;}
	var thediv = 'sh_npop';	var xdiv = 'npop_act'; var pt=''; var if_cl=false;
	if (sect==1){pt='My Friends'; go_pg='notify_fri_my';} 
	if (sect==2){pt='Online Friends'; go_pg='notify_fri_on';}
	if (sect==3){pt='Send Comment to'; go_pg='pop_comment';} 
	if (sect==4){pt='Send Message to'; go_pg='pop_message';}
	
	if ($(thediv).style.display=="none" || updNWin!=0){	
		if (updNWin!=0){updDiv(xdiv,999)}
		$(thediv).style.display=="block";
		if (sect!=0){
			new Ajax.Updater('npop_con',thedom+'/ajax/'+go_pg+'.php?'+params, {evalScripts: true,onSuccess: function (res){updDiv(xdiv,'');updDiv('npop_title',pt);}});}
		if (updNWin==0){
			numNWin = 0;
			Effect.SlideDown($(thediv), {duration: .5});}
	}else{
		Effect.SlideUp($(thediv), {duration: .5});	
		$(thediv).style.display=="none";		
		setTimeout("updDiv('npop_con','<div class=\"tmg20 ali_c\"><img src=\""+thedom+"/images/loading.gif\" /><span class=\"lmg5 fb\">Loading...</span></div>');updDiv('npop_title','');",500);
		if_cl = true;
	}	
	if(!if_cl){updNWin = sect;}
}
function ch_notify(){
	if (updNPop==0 && numNWin<=180){
	updNPop=1;
	new Ajax.Request(thedom+'/ajax/notify_update.php', {
		  method: 'post',
		  onSuccess: function (res){
		  	if(res.responseText!=''){
				updDiv('nnew_con',res.responseText);
				$('sh_nnew').style.display=="block";
				Effect.SlideDown($('sh_nnew'), {duration: .5});
				numNWin = 0;
			}else{updNPop=0;}
		}
	});}
	numNWin++;
}
function hd_notify(){
	Effect.SlideUp($('sh_nnew'), {duration: .5}); 
	updNPop=0;	
}

function MPage(theurl,thetitle,thewid){
	if (thewid=="" || thewid==null || thewid==0) thewid = 520;
	Modalbox.show(theurl, {title: thetitle, width: thewid, afterLoad: MBRESIZE});
}

function modalAdd(){
	Modalbox.show(thedom+'/ajax/add_element.php', {title: 'Add Element', width: 520, afterLoad: MBRESIZE});
}

function modalAddP(pgtitle,theparam){
	new Ajax.Updater('email_photos',thedom+'/ajax/email_pg.php?'+theparam, {evalScripts: true});		
	divTog('email_to');	
}

function MBRESIZE(){Modalbox.resizeToContent();}

var swfu;
function uploader(){	
	var phiq = $('phiq').innerHTML; var paid = $('aid').innerHTML; var gid = $('gid').innerHTML; var ims = $('ims').innerHTML; var ids = $('ids').innerHTML;
	swfu = new SWFUpload({		
		upload_url: ids+"scripts/uploader/upload.php?phiq="+phiq+"&aid="+paid+"&gid="+gid+"&ims="+ims,	

		file_size_limit : "11000",
		file_types : "*.jpg;*.jpeg;*.gif",
		file_types_description : "Image Files",
		file_upload_limit : "0",

		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete,
		queue_complete_handler : queueComplete,	

		button_image_url : thedom+"/images/frm_but.png",
		button_placeholder_id : "spanButtonPlaceholder",
		button_width: 116,
		button_height: 25,
		button_text : '<span class="ulbutton">Browse Images</span>',
		button_text_style : '.ulbutton { font-family: Arial, sans-serif; font-size: 11pt; }',
		button_text_top_padding: 4,
		button_text_left_padding: 18,
	
		flash_url : ids+"scripts/uploader/swfupload.swf",

		custom_settings : {
			upload_target : "divFileProgressContainer",
			progressTarget : "fsUploadProgress",
			cancelButtonId : "btnCancel"
		},

		debug: false
	});
}
function edit_umusic(){
	Modalbox.show(thedom+'/edit/profile_umusic.php', {title: 'Edit Music Player', width: 520, afterLoad: MBRESIZE});}


//Calendar
var req;
function cal_navigate(month,year,evt,tbl,thecal,popup,hol,mid,elid) {
	var params = "month="+month+"&year="+year+"&event="+evt+"&tbl="+tbl+"&thecal="+thecal+"&popup="+popup+"&hol="+hol+"&mid="+mid+"&elid="+elid;
	new Ajax.Updater(thecal,thedom+'/ajax/build_calendar.php', {
		method: 'post',
		evalScripts: true,
		parameters: params
	});	
}

function showJump(obj,tbl,thecal,popup,hol,mid,elid) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	var jump = document.createElement("div");
	jump.setAttribute("id","jump");
	jump.style.position = "absolute";
	jump.style.top = curtop+15+"px";
	jump.style.left = curleft+"px";
	var output = '<select id="'+tbl+'month">\n';
	var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	var n; var d=new Date();
	for(var i=0;i<12;i++) {
		n = ((i+1)<10)? '0'+(i+1):i+1;
		var seltxt = "";
		if (d.getMonth()==i) {seltxt = "selected='selected'";}
		output += '<option value="'+n+'" '+seltxt+'>'+months[i]+'  </option>\n';
	}
	output += '</select> \n<select id="'+tbl+'year">\n';
	for(var i=2006;i<=d.getFullYear()+3;i++) {
		var seltxt = "";
		if (d.getFullYear()==i) {seltxt = "selected='selected'";}
		output += '<option value="'+i+'" '+seltxt+'>'+i+'  </option>\n';
	}
	output += '</select> <a href="javascript:jumpTo(\''+tbl+'\',\''+thecal+'\',\''+popup+'\',\''+hol+'\',\''+mid+'\',\''+elid+'\')"><img src="'+thedom+'/images/icons/but_forward.png" alt="Go" class=tmg5 /></a> <a href="javascript:hideJump()"><img src="'+thedom+'/images/icons/delete.png" alt="Close" class=tmg5 /></a>';
	jump.innerHTML = output;
	document.body.appendChild(jump);
	jump = null;
}

function hideJump(tbl,thecal,popup,hol) {
	document.body.removeChild($("jump"));	
}

function jumpTo(tbl,thecal,popup,hol,mid,elid) {
	var m = $(tbl+"month");
	var y = $(tbl+"year");
	cal_navigate(m.options[m.selectedIndex].value,y.options[y.selectedIndex].value,'',tbl,thecal,popup,hol,mid,elid);
	hideJump();
}

function addDiv(xdiv,thetxt,theid){
	if (thetxt==999){thetxt="<img src='"+thedom+"/images/loading.gif'/>";}
	var newdiv = document.createElement("div");
	var thediv = $(xdiv);
	if (thetxt.match('</id>')){
		theid = thetxt.substr(4,thetxt.indexOf('</id>')-4);
		thetxt = thetxt.substr(thetxt.indexOf('</id>')+5);}
	newdiv.innerHTML = thetxt;		
	newdiv.id = "item_"+theid;
	thediv.appendChild(newdiv);	
	newdiv = null;
}
function updDiv(xdiv,thetxt,doFade){
	if (doFade==undefined){doFade=0;}
	if ($(xdiv)!=null){
		if (thetxt==999){thetxt="<img src='"+thedom+"/images/loading.gif'/>";}
		var newdiv = document.createElement("tag");
		var thediv = $(xdiv);
		while(thediv.firstChild){ thediv.removeChild(thediv.firstChild);}
		newdiv.innerHTML = thetxt;	
		thediv.appendChild(newdiv);
		if (doFade==1){
			Effect.Appear($(xdiv), {duration: .05});
			setTimeout("Effect.Fade('"+xdiv+"', {duration: 0.5})", 4000);
			$(xdiv).style.display=''; Effect.Appear(xdiv);
		}
		newdiv = null; thediv = null; 
	}
}
function delDiv(xdiv,theid){
	xdiv = $(xdiv);
	theid = $(theid);	
	Effect.Fade(theid, {duration: 0.5, afterFinish: function(){xdiv.removeChild(theid);} });
}
function chasect(xdiv,theurl,params){
	var thediv = "section_" + xdiv + "C";
	new Ajax.Updater(thediv,theurl, {
		method: 'post',
		evalScripts: true,
		parameters: params
	});	
}

function inedit(thediv,theurl,width,height) {
	var thetxt = stripHTML($(thediv).innerHTML);	
	thetxt = thetxt.replace( /\"/g, '&#34;' );
	if (width!=""){var thesize = width;}else{var thesize=15;}
	if (height!=""){var thestyle = "height:"+height+"px; font-size:"+(height-6)+"px;";}
	$(thediv).onclick='';
	var inputtxt = "<form name='F"+thediv+"' class='inedit' onsubmit=\"inedit2('"+thediv+"','"+theurl+"','"+width+"','"+height+"'); return false;\">";
	inputtxt+= "<input type='text' id='Z"+thediv+"' value=\""+thetxt.replace(/^\s+/,"")+"\" width='"+thesize+"' maxlength='100' class='indiv inedit_txt bord_mblue' style='background:#ffffff; "+thestyle+"' />";
	inputtxt+= "<input class='mg_1' type='image' src='"+thedom+"/images/icons/pencil.png' /></form>";
	updDiv(thediv,inputtxt,width,height);
}

function inedit2(thediv,theurl,width,height) {	
	var thetxt = $("Z"+thediv).value;
	thetxt = thetxt.replace( /\"/g, '&#34;' );
	$(thediv).onclick= function(){inedit(thediv,theurl,width,height)};
	updDiv(thediv,thetxt);
	new Ajax.Request(thedom+'/ajax/inline_'+ theurl +'.php', {
		method: 'post',
		evalScripts: true,
		parameters: "txt="+escape(thetxt) + "&id="+thediv
	});	
}

function ineditT(add_num,thediv,theurl) {
	var thetxt = $(thediv).innerHTML;	
	thetxt = thetxt.replace( /\"/g, '&#34;' );
	thetxt = thetxt.replace('<tag>',''); thetxt = thetxt.replace('</tag>',''); thetxt = thetxt.replace(/<br>/g,'\n');
	$(thediv).onclick='';
	var inputtxt = "<form name='F"+thediv+"' class='inedit' onsubmit=\"ineditT2('"+add_num+"','"+thediv+"','"+theurl+"'); return false;\">";
	inputtxt+= "<textarea type='text' id='Z"+thediv+"' style='width:98%;' rows='5' class='inedit_txt'/>"+thetxt+"</textarea><br>";
	inputtxt+= "<input class='ulbutton' type='submit' value='Edit Note' /><div class='lmg10 lgray'>Accepts basic HTML: &lt;b&gt;&lt;em&gt;&lt;p&gt;&lt;ol&gt;&lt;li&gt;...</div></form>";
	updDiv(thediv,inputtxt);
}

function ineditT2(add_num,thediv,theurl) {	
	var thetxt = $("Z"+thediv).value;
	thetxt = thetxt.replace( /\"/g, '&#34;' );
	upd_elm(add_num,'kt=1&eltxt1='+escape(thetxt));
	load_con('section_' + add_num);	
	/*$(thediv).onclick= function(){ineditT(add_num,thediv,theurl)};	
	updDiv(thediv,thetxt);	*/
}

function send_email(from,to,subject,message) {
	new Ajax.Request(thedom+'/ajax/send_email.php', {
		  method: 'post',
		  parameters: "from="+from+"&to="+to+"&subject="+subject+"&message="+message,
		  onSuccess: function (res){		
			updDiv('confirm_res',res.responseText);
			setTimeout("$('show_emails').className=''; $('show_form').className='invis';updDiv('confirm_res','');", 2000);	
			
		}
	});
}

function del_it(thetbl,idf,theid,thecon,params) {
	new Ajax.Request(thedom+'/ajax/del_it.php', {
		  method: 'post',
		  parameters: "tbl=" + thetbl + "&idf=" + idf + "&id=" + theid,
		  onSuccess: function (res){	
		  	if (thecon!='' && thecon!='undefined'){load_con('section_' + thecon,'n=0&'+params)}
		}
	});
}

function app_it(thetbl,theapp,idf,theid,thecon,params) {
	new Ajax.Request(thedom+'/ajax/app_it.php', {
		  method: 'post',
		  parameters: "tbl=" + thetbl + "&app=" + theapp + "&idf=" + idf + "&id=" + theid,
		  onSuccess: function (res){	
		  	if (thecon!='' && thecon!='undefined'){load_con('section_' + thecon,'n=0&'+params)}
		}
	});
}

function divTog(thediv,doC,chTxt) {
	if (!doC){doC = 0;}
	if ($(thediv).style.display=="none"){	
		if (doC==1){setCookie(thediv,'T',365);}
		if (chTxt){updDiv(chTxt,'(less info...)')};
		Effect.SlideDown($(thediv), {duration: .5});	
	}else{
		if (doC==1){setCookie(thediv,'M',365);}
		if (chTxt){updDiv(chTxt,'(more info...)')};
		Effect.SlideUp($(thediv), {duration: .5});	
	}
}

function divSH(thediv) {
	if ($(thediv).style.display=="none"){	
		$(thediv).style.display="";
	}else{
		$(thediv).style.display="none";}
}

function div_S(thediv) { $(thediv).style.display=""; }
function div_H(thediv) { $(thediv).style.display="none"; }

function divSH2(thediv,chTxt) {
	if ($(thediv).style.display=="none"){	
		$(thediv).style.display="";
		if (chTxt){updDiv(chTxt,'(less info...)');}	
	}else{
		$(thediv).style.display="none";
		if (chTxt){updDiv(chTxt,'(more info...)');}
	}
}

function theNav(thediv,thefile,params,cir,updr) { 
	updAds();
	if (cir!="1" && cir!= undefined){updDiv(thediv,'999');}
	if (updr!="" && updr!= undefined){updDiv(updr,'999');}
	new Ajax.Updater(thediv,thedom+'/ajax/'+thefile+'.php', {
		method: 'post', evalScripts: true, parameters: params,
		onSuccess: function (res){if (updr!=""){updDiv(updr,'');}}
	});	
}

function theNav2(thediv,thefile,params,cir,updr) {
	if (cir!="1" && cir!= undefined){updDiv(thediv,'999');}
	if (updr!="" && updr!= undefined){updDiv(updr,'999');}
	new Ajax.Updater(thediv,thedom+'/'+thefile+'.php', {
		method: 'post', evalScripts: true, parameters: params,
		onSuccess: function (res){if (updr!=""){updDiv(updr,'');}}
	});	
}

function getCheckedValue(radioObj) {
	if(!radioObj) {return "";}
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked){
			return radioObj.value;
		}else{
			return "";}
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {return radioObj[i].value;}
	}
	return "";
}
function loadsb() {	
	thepage = $('sidebarnum').innerHTML;
	themem = $('sidebarmem').innerHTML;
	new Ajax.Updater('sidebardiv',thedom+'/includes/sidebar.php', {
		method: 'post',
		evalScripts: true,
		parameters: "m="+themem+"&p="+thepage
	});
}
function ToggleAll(theElement) {
	 var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
	  if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm[z].checked = theElement.checked;
	  }
	 }
}
function updAds(){
	/*updDiv('adnav','<IFRAME FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH=728 HEIGHT=90 SRC="http://optimizedby.rmxads.com/st?ad_type=iframe&ad_size=728x90&section=581205"></IFRAME>');*/
}
function updAds160(){
	/*updDiv('adnav160','<iframe src="'+thedom+'/includes/ad_160.php" height="600" width="160" marginheight="0" marginwidth="0" frameborder="0" scrolling="no"></iframe>');*/
}

function edit_bg(type,s) {
	new Ajax.Updater('edit_bg',thedom+'/includes/customize.php?type='+type+'&s='+s, {evalScripts: true});		
	divTog('edit_bg');	
}
function edit_bgr(type,s) {
	/*new Ajax.Updater('edit_bg',thedom+'/includes/customize.php?type='+type+'&s='+s, {evalScripts: true});*/	
	if (type==0 || type==3){
		var inst = "";
		if (type==3){ inst = "b";}
		var thebg = getCookie('bg_'+inst+'img');	
		if (thebg!=""){
		if (thebg.match(".")){document.body.style.backgroundImage = "url("+thedom+"/images/bgs/bg/"+thebg+")";
		}else{document.body.style.backgroundImage = ""; document.body.style.backgroundColor = "#"+thebg;}}
		
		var thenav = getCookie('bg_'+inst+'nav');
		if (thenav!=""){
		if (thenav.match(".")){$('headwrap').style.backgroundImage = "url("+thedom+"/images/bgs/nav/"+thenav+")";
		}else{$('headwrap').style.backgroundImage = ""; $('headwrap').style.backgroundColor = "#"+thenav;}}
		
		var thebor = getCookie('bg_'+inst+'bor');
		var bgdiv = thebor.substr(0,thebor.indexOf("."));
		if (thebor!=""){ change_br(thebor,bgdiv,0,1); }
	}
}


function edit_bgc(bg_nav,bg_bor,bg_borw,bg_img,bg_head,bg_foot,type,s) {
	new Ajax.Request(thedom+'/ajax/edit_bg.php',{method: 'post',
					 parameters: 'bgnav='+bg_nav+'&bgbor='+bg_bor+'&bgborw='+bg_borw+'&bgimg='+bg_img+'&bg_head='+bg_head+'&bg_foot='+bg_foot+'&type='+type+'&s='+s,
					 onSuccess: function (res){updDiv('upd_cust','Changes Saved!',1);}});	
	if (type!=1){
		if (type==3){ var inst = "b";}
		setCookie('bg_'+inst+'img',getCookie('bg_'+inst+'imgT'),365);
		setCookie('bg_'+inst+'bor',getCookie('bg_'+inst+'borT'),365);
		setCookie('bg_'+inst+'borw',getCookie('bg_'+inst+'borwT'),365);
		setCookie('bg_'+inst+'nav',getCookie('bg_'+inst+'navT'),365);}	
}
function ch_nav(thenum){
	for (i=0;i<=2;i++){	$('nav_type'+i).style.display='none'; }
	$('nav_type'+thenum).style.display='';		
}
function ch_bg(thenum){
	for (i=0;i<=2;i++){$('bg_type'+i).style.display='none'; }
	$('bg_type'+thenum).style.display='';
}
function change_bg(thebg,bgdiv,type) {
	$('val_bg').innerHTML = thebg;
	var i=11; var endi = parseInt($('cnt_bg').innerHTML)+10;
	while (i <= endi){
		$('bg_'+i).style.border="1px solid #5a86b3"; $('bg_'+i).style.margin="2px"; i=i+1;}
	if (type!=1){
		document.body.style.backgroundColor = "";document.body.style.backgroundImage = "";
		document.body.style.backgroundRepeat = "";document.body.style.backgroundAttachment = "";
		if (bgdiv<=800){
			document.body.style.backgroundImage = "url("+thedom+"/images/bgs/bg/"+thebg+")";
			$('bg_'+bgdiv).style.border="3px solid #5a86b3"; $('bg_'+bgdiv).style.margin="0";	
		}else{
			if (bgdiv==888){document.body.style.backgroundImage = thebg;}
			if (bgdiv==999){document.body.style.backgroundColor = "#"+thebg;}			
		}
		if (thebg=='10.jpg'){document.body.style.backgroundRepeat = "repeat-x";document.body.style.backgroundAttachment = "fixed";document.body.style.backgroundColor = "#b8ddf7";}
		if (type==0){setCookie('bg_imgT',thebg,365);}
		if (type==2){setCookie('bg_gimgT',thebg,365);}
		if (type==3){setCookie('bg_bimgT',thebg,365);}
	}else{
		if (bgdiv<=800){$('bg_'+bgdiv).style.border="3px solid #5a86b3"; $('bg_'+bgdiv).style.margin="0";}
	}
}

function change_br(thebr,bgdiv,type,redo) {
	$('val_bor').innerHTML = thebr;
	var thebrw = $('val_borw').innerHTML;
	if (type!=1){
		$$('.rbox').each(function (el) {return $(el).style.borderColor = "#"+thebr;});
		$$('.rbox').each(function (el) {return $(el).style.borderWidth = thebrw+"px";});
		
		if(redo!=1){
			  if (type==0){setCookie('bg_borT',thebr,365);setCookie('bg_borwT',thebrw,365);}
			  if (type==2){setCookie('bg_gborT',thebr,365);setCookie('bg_gborwT',thebrw,365);}
			  if (type==3){setCookie('bg_bborT',thebr,365);setCookie('bg_bborwT',thebrw,365);}
		}
	}
}
function change_nav(thebg,bgdiv,type) {
	$('val_nav').innerHTML = thebg;
	var i=11; var endi = parseInt($('cnt_hd').innerHTML)+10;
	while (i <= endi){
		$('nav_'+i).style.border="1px solid #5a86b3"; $('nav_'+i).style.margin="2px"; i=i+1;}
	if (type!=1){
		if (thebg=='TRAN'){
			$('headwrap').style.backgroundImage = "url()";
		}else{
			if (bgdiv!=999){
				$('headwrap').style.backgroundImage = "url("+thedom+"/images/bgs/nav/"+thebg+")";
				$('nav_'+bgdiv).style.border="3px solid #5a86b3"; $('nav_'+bgdiv).style.margin="0";	
			}else{$('headwrap').style.backgroundImage = ""; $('headwrap').style.backgroundColor = "#"+thebg;
				if (thebg=="") {$('headwrap').style.backgroundColor = "";}}
		}
		if (type==0){setCookie('bg_navT',thebg,365);}
		if (type==2){setCookie('bg_gnavT',thebg,365);}	
		if (type==3){setCookie('bg_bnavT',thebg,365);}	
	}else{
		if (bgdiv!=999){$('nav_'+bgdiv).style.border="3px solid #5a86b3"; $('nav_'+bgdiv).style.margin="0";}
	}	
}

function cr_embed(fsrc_url,fsrc,fbord,fbordt,fbcol,fwid,fhei,fhead,upd,type){
	var myframe = "<iframe src='"+fsrc_url+"' height='"+fhei+"' width='"+fwid+"' style='border:"+fbord+"px "+fbordt+" #"+fbcol+";' frameborder='0' marginheight='0' marginwidth='0'></iframe>";
	$('frametxt').value = myframe;	
	if (upd==1){
		new Ajax.Request(thedom+'/ajax/edit_embed.php',{method: 'post',
			 parameters: 'type='+escape(type)+'&fsrc='+escape(fsrc)+'&fhei='+escape(fhei)+'&fwid='+escape(fwid)+'&fbord='+escape(fbord)+'&fbordt='+escape(fbordt)+'&fbcol='+escape(fbcol)+'&fhead='+escape(fhead),
			 onSuccess: function (res){updDiv('upd_cust','Updated & Saved!',1);}});	
	}
}

function toolTip(type,thediv,thetxt,target,twid,thei,xoff,yoff) {
	//type: div=1,ajax=2,text=3		
	var strtip='topLeft'; var strtarget='bottomLeft';
	if (target==2){strtip='topRight'; strtarget='bottomRight';}	
	if(xoff == undefined) {xoff=40;} if(yoff == undefined) {yoff=-5;}

	if (type==1){
		new Tip(thediv, $(thetxt).innerHTML, {stem: strtip, hook: { tip: strtip, target: strtarget },offset:{x: xoff,y: yoff},width: twid, height:thei});}		
	if (type==2){
		new Tip(thediv, {ajax:{url: thetxt,options:{
				method: 'post',
				onComplete: function() { if ($('numvis')){pagewidth('resizer',$('numvis').value);} }
				}},showOn: 'click', stem: strtip, hook:{tip: strtip,target: strtarget},offset:{x: xoff,y: yoff},width: twid, height:thei});}
	if (type==3){
		new Tip(thediv, thetxt, {showOn: 'click', stem: strtip, hook: { tip: strtip, target: strtarget },offset:{x: xoff,y: yoff},width: twid, height:thei});}			
}

function CountLeft(field, count, max) {
	if (field.value.length > max){
		field.value = field.value.substring(0, max);
	}else{
		count.value = max - field.value.length;}
}

function chk_imp(imname,val,theid) {
	updDiv('chk_im_'+theid,999);
	new Ajax.Request(thedom+'/ajax/get_im_state.php', {
		method: 'post', parameters: 'imname='+imname+'&val='+val,
		onSuccess: function (res){
			updDiv('chk_im_'+theid,res.responseText);
		}
	});	
}

function cselect(selcat,type){
	if (type!=1){$('csel_1').style.display='none';} 
	$('csel_2').style.display='none'; $('csel_3').style.display='none';
	if (type==1 || type==2 || type==3){$('csel_4').style.display='none';}
	
	if (type!=1){$('chs_1').className='b_arrow';} 
	 $('chs_2').className='b_arrow'; $('chs_3').className='b_arrow';
	 if (type==1 || type==2 || type==3){$('chs_4').className='b_arrow';}
	 
	$('csel_'+selcat).style.display='';
	$('chs_'+selcat).className='b_arrow_on';	
}
/*function upd_fade(thenum){
	for (i=0;i<=8;i++){	$('tut'+i).className='but_fade bord_gray'; }
	$('tut'+thenum).className='but_fade_on bord_gray';
}*/

function newVideo(thediv,width,height,thefile,fullsc,image,autos){
	if ($(thediv).innerHTML==""){
	var s1 = new SWFObject(thedom+'/swf/player.swf',thediv,width,height,'9');
	s1.addParam('allowfullscreen',fullsc);
	s1.addParam("wmode","transparent");
	s1.addParam('allowscriptaccess','always');
	s1.addParam('flashvars','file='+thefile+'&abouttext=Visit%20Miogate&aboutlink='+thedom+'/&skin='+thedom+'/swf/modieus.swf&channel=7847&plugins=ltas&autostart='+autos+'&image='+image);
	s1.write(thediv);
	}
}

function stripHTML(thestr) {     
	return thestr.replace(/<\/?[^>]+>/gi, ""); 
}
function escapeHTML(thestr) {     
	return thestr.escapeHTML(); 
}

function load_Editor(){
	tinyMCE_GZ.init({themes : 'advanced',languages : 'en',disk_cache : true,debug : false});
	
	tinyMCE.init({mode : "exact",theme : "advanced",skin : "o2k7", skin_variant : "silver",elements : "details",
		plugins : "safari,style,table,spellchecker,layer,advhr,advimage,advlink,emotions,inlinepopups,insertdatetime,preview,contextmenu,paste,fullscreen,noneditable,",
		theme_advanced_buttons1 : "fontselect,fontsizeselect,forecolor,backcolor,|,bold,italic,underline,strikethrough,|,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,outdent,indent",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,link,unlink,|,advhr,charmap,emotions,image,|,insertdate,inserttime,|,insertlayer,moveforward,movebackward,absolute,|,spellchecker,cleanup,fullscreen,preview,code,|,undo,redo",
		theme_advanced_buttons3 : "",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
		content_css : thedom+"/css/css.css",
		external_image_list_url : thedom+"/scripts/editor/image_list.js"	
	});	
}