function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.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 MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i < a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function TT_doSearch(){
	if ( document.search_form != null ){
		document.search_form.action = document.search_form.fAction.value;
		document.search_form.fDoSearch.value="true";
		document.search_form.submit();
	}

}

function TT_checkSearch(){
	if ( document.search_form.fDoSearch.value == "true" ){
		return true;
	}else{
		return false
	}

}

var pic_popup=null;
function popup_picture(src, w, h)
{
  	var doc = '<html><head>' +
			  '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">' +
			  '<title>TagTag.com</title></head>' +
			  '<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">' + 
			  '<table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0">' + 
			  '<tr><td align="center" valign="top"><a href="#"><img src="'+ src +'" border="0" onClick="window.close();"></a></td></tr>' + 
			  '</table></body>';
	
	if (w == null) w = 500;
  	if (h == null) h = 500;
	if (pic_popup==null || pic_popup.closed) {
		pic_popup=window.open("","pic_popup",'toolbar=no,width='+ w +',height='+ h +',resizable=no,scrollbars=no,directories=no,status=no,menubar=no,location=no');
		pic_popup.document.write(doc);
		pic_popup.creator = self;      
	}
	else {
		pic_popup.close();
		pic_popup=window.open("","pic_popup",'toolbar=no,width='+ w +',height='+ h +',resizable=no,scrollbars=no,directories=no,status=no,menubar=no,location=no');
		pic_popup.document.write(doc);
		pic_popup.focus();
	}
	
}



function gowap_check(){
	var fURL = document.WAPbrowser.fURL.value;

	if (fURL.indexOf('.')==-1){
		return false;
	}
	return true;
}

function gowap (a){
	var xURL;
	var wurl;
	var str2;
	var datum = new Date();
	
	var w = 270;
	var h = 340;

	// is there an input parameter? if not we read url from the form

	if (a==null || a==''){
		xURL= document.WAPbrowser.fURL.value;
	}else{
		xURL=a;
	}
	if (!xURL.indexOf("http://")) xURL = "http://" + xURL;
	
	wurl=escape(xURL);
	if ( document.location.href.indexOf("tagtag.com") >= 0 ){
		str2="http://emulator.tagtag.com/wapemulator.cgi?O__SKIN=S1&wurl=" + wurl;
	}else{
		str2="http://tagtag.inetis.com/cgi/wapemulator.cgi?O__SKIN=S1&wurl=" + wurl;
	}
	params = 'width='+ w +',height='+ h + ',toolbar=no,location=yes,scrollbars=yes,resizable=yes';
	
	v = window.open(str2,'TagTag',params);
}

///////////////////////////// MAIN ///////////////////
function TTCHECK (xURL) {
	
	if (xURL=='') {
		xURL="http://" + document.TTFORM.TTURL.value;
		}
	else {
		xURL= xURL;
	}
	
	// is URL valid?
	
	if (xURL.indexOf('.')==-1){
		return false;
	}
	
	return true;
}


function TTBROWSE (xURL, xSKINID) {
	
	var wurl;
	var datum = new Date();

	datum = escape(datum.getTime());
	
	if (xURL=='') {
		if (document.TTFORM.TTURL.value == '') {
			return;
		}
		xURL= document.TTFORM.TTURL.value;
		}
	else {
		xURL= xURL;
	}
	// is there a skin parameter?
	
	if (xSKINID=="") {
		xSKINID = "P1";
	}

	wurl=escape(xURL);
	v = window.open('http://emulator.tagtag.com/wapemulator.cgi?O__SKIN=' + xSKINID + '&wurl=' + wurl + '&dummy='+datum, 'TagTag','width=220,height=285');
}



///////////////////////////////////////
	top.name = "prvi";
	var Win1 = null;
	var Win2 = null;
    
       function Pscreen() {   	
       		if (Win1==null || Win1.closed) {
					Win1=window.open("demo/demo1.htm","demotour",'toolbar=no,width=320,height=400,directories=no,status=no,scrollbars=no,resize=no,menubar=no,location=no,copyhistory=no');
					Win1.creator = self;         
				}
       }            
       function Iscreen() {   	
       		if (Win2==null || Win2.closed) {
					Win2=window.open("invite1.html","invitation",'toolbar=no,width=360,height=350,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,location=no,copyhistory=no');
					Win2.creator = self;         
				}
       } 
	   
       function SiteStat(url) {   	
       		if (Win1==null || Win1.closed) {
					Win1=window.open(url,"sitestat",'toolbar=no,width=320,height=200,directories=no,status=no,scrollbars=no,resize=no,menubar=no,location=no,copyhistory=no');
					Win1.creator = self;         
				}
       } 	   
//////////////////////////////////////////


var okno = null;
function doPlay(id)
{	
	var data = 	'<html><head>' +
				'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">' +
				'<title>TagTag.com</title></head>' +
				'<frameset cols="100%,*" frameborder="no" border="0" framespacing="0">' +
				'<frame src="ringtone_player.php3?fCode='+ id +'" name="main">' +
				'<frame src="" name="invisible" scrolling="no" noresize>' +
				'<noframes><body></body></noframes></frameset></html>';
				
	var w = 350;
  	var h = 100;

	if (okno==null || okno.closed) {
		okno=window.open("" ,"midi_player",'toolbar=no,width='+ w +',height='+ h +',resizable=no,scrollbars=no,directories=no,status=no,menubar=no,location=no');
		okno.document.write(data);
		okno.creator = self;      
	}
	else {
		okno.document.write(data);
		okno.focus();
	}
	
}


//////////////////////////////////


	function DeleteConfirm () {
		var form = document.guestbook;
		var count = 0;
		for (i=0 ; i<form.length ; i++){
			if (form[i].type=="checkbox")
				if (form[i].checked) count++;
		
		}
		
		if(count > 0){
			if ( confirm("Delete selected entries?") )
			{ 
				document.guestbook.gbDelete.value=true;
				document.guestbook.submit();
			}
		}else{
			alert("Select one or more entries first.");
		} 
	}
	
	function select_all(){
		var form = document.guestbook;
		for (i=0 ; i<form.length ; i++){
			if (form[i].type=="checkbox")
				form[i].checked=true;
		
		}
	}
	function select_none(){
		var form = document.guestbook;
		for (i=0 ; i<form.length ; i++){
			if (form[i].type=="checkbox")
				form[i].checked=false;
		
		}
	}

/////////////////////////////////////////////////////////

	function DeleteConfirmMail (url, name) {
		if ( confirm("Do you realy want to delete "+ name +"?") ){ 
			document.location=url;
		} 
	}
	
	function DeleteConfirmSite (url, name) {
		if ( confirm("Do you realy want to delete http://tagtag.com/"+ name +" ?") ){ 
			document.location=url;
		} 
	}
