	PreImage8 = new Image(50,33);
	PreImage8.src = "/pics/submit_new_down.gif";	

//--------------------------------------------------------------------------------------------------------------------------------------------
//comment textfield
//--------------------------------------------------------------------------------------------------------------------------------------------

function textfield_status(status,id, textValue, classname) {
 	if(status == 'onfocus' && document.getElementById(id).value == textValue) {
		document.getElementById(id).value = "";
		document.getElementById(id).setAttribute("class", classname);		
	}
 	else if(status == 'onblur' && document.getElementById(id).value == '') {
		document.getElementById(id).value = textValue;
		document.getElementById(id).setAttribute("class", classname);		
	}	
	
}



//--------------------------------------------------------------------------------------------------------------------------------------------
//VALIDATE DOMAIN
//--------------------------------------------------------------------------------------------------------------------------------------------

function checkDomain(nname)
{
var arr = new Array(
'.com','.net','.org','.biz','.coop','.info','.museum','.name',
'.pro','.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag',
'.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw',
'.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm',
'.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc',
'.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr',
'.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz',
'.ec','.ee','.eg','.eh','.er','.es','.et','.fi','.fj','.fk','.fm',
'.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm',
'.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy','.hk','.hm',
'.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq',
'.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li',
'.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg',
'.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt',
'.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng',
'.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf',
'.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py',
'.qa','.re','.ro','.rw','.ru','.sa','.sb','.sc','.sd','.se','.sg',
'.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.sv',
'.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tm','.tn',
'.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.um',
'.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.ws',
'.wf','.ye','.yt','.yu','.za','.zm','.zw');

var mai = nname;
var val = true;

var dot = mai.lastIndexOf(".");
var dname = mai.substring(0,dot);
var ext = mai.substring(dot,mai.length);
//alert(ext);
	
if(dot>2 && dot<57)
{
	for(var i=0; i<arr.length; i++)
	{
	  if(ext == arr[i])
	  {
	 	val = true;
		break;
	  }	
	  else
	  {
	 	val = false;
	  }
	}
	if(val == false)
	{
		 return false;
	}
	else
	{
		for(var j=0; j<dname.length; j++)
		{
		  var dh = dname.charAt(j);
		  var hh = dh.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || hh==45 || hh==46)
		  {
			 if((j==0 || j==dname.length-1) && hh == 45)	
		  	 {

			      return false;
		 	 }
		  }
		else	{

			 return false;
		  }
		}
	}
}
else
{

 return false;
}	

return true;
}




//--------------------------------------------------------------------------------------------------------------------------------------------
//AJAX commentpost
//--------------------------------------------------------------------------------------------------------------------------------------------


function ajaxform(thisform,formhandler,formid,comments)
{

	if(thisform.elements[1].value == null || thisform.elements[1].value == "" || thisform.elements[1].value.match("Your name")) {
		document.getElementById('comment_directions' + formid).innerHTML = '<b>Please, tell me your name.</b>'; 
	
	}else if(thisform.elements[1].value.match("hellojere") || (thisform.elements[1].value.match("hello") && thisform.elements[1].value.match("jere"))) {
		document.getElementById('comment_directions' + formid).innerHTML = '<b>Hey, don\'t try to be me!</b>'; 	
		
		
	}else if(thisform.elements[1].value.length < 2 || thisform.elements[1].value.length > 20) {
		document.getElementById('comment_directions' + formid).innerHTML = '<b>The length of your name has to be between 2 and 20 characters.</b>'; 		

	}else if(thisform.elements[2].value != null && thisform.elements[2].value != "Website" && checkDomain(thisform.elements[2].value) == false) {
		document.getElementById('comment_directions' + formid).innerHTML = '<b>Check your website address again, it should be like www.domain.com.</b>'; 

	}else if(thisform.elements[3].value == null || thisform.elements[3].value == "" || thisform.elements[3].value == "Comment") {
		document.getElementById('comment_directions' + formid).innerHTML = '<b>Your comment field is empty.</b>'; 

	}else if(thisform.elements[3].value.match(">")) {
		document.getElementById('comment_directions' + formid).innerHTML = '<b>I\'m sorry, HTML is not allowed anymore.</b>'; 		
		
	}else if(thisform.elements[3].value.length > 4000) {
		document.getElementById('comment_directions' + formid).innerHTML = '<b>The length of your comment has to be less than 4000 characters.</b>'; 				

	}else {

	var comment = parseInt(comments);
	comment+=1;
	if(comment != 1)comment+="&nbsp;comments";
	else comment+="&nbsp;comment";

	if(thisform.elements[2].value != "") var comment_text =	'<a href="' + thisform.elements[2].value + '" target="_blank" class="comname">' + thisform.elements[1].value + '</a>';

	else var comment_text = '<span class="comname">' + thisform.elements[1].value + '</span>';

	
    //General Purpose Ajax form submitter.
    //Written by Carl(bag) @ Thybag.co.uk

    // Set up data variable
    var formdata = "";

    // Set up Ajax request variable
    try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: Could not load page.");}

    // Loop through form fields
    for (i=0; i < thisform.length; i++)
    {
         //Build Send String
         if(thisform.elements[i].type == "text"){ //Handle Textbox's
                  formdata = formdata + thisform.elements[i].name + "=" + escape(thisform.elements[i].value) + "&";
         }else if(thisform.elements[i].type == "textarea"){ //Handle textareas
                  formdata = formdata + thisform.elements[i].name + "=" + escape(thisform.elements[i].value) + "&";
         }else if(thisform.elements[i].type == "checkbox"){ //Handle checkbox's
                 formdata = formdata + thisform.elements[i].name + "=" + thisform.elements[i].checked + "&";
         }else if(thisform.elements[i].type == "radio"){ //Handle Radio buttons
                  if(thisform.elements[i].checked==true){
                     formdata = formdata + thisform.elements[i].name + "=" + thisform.elements[i].value + "&";
                  }
         }else{
                  //finally, this should theoretically this is a select box.
                  formdata = formdata + thisform.elements[i].name + "=" + escape(thisform.elements[i].value) + "&";
         }
    }

    //Send Ajax Request
    xmlhttp.onreadystatechange = function(){
               //Check page is completed and there were no problems.
               if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
                      //What to do once the form is submitted - to inform the user.
                    
                    
                    document.getElementById('comment_amount' + formid).innerHTML = comment;  
                                        
					document.getElementById('added_comment' + formid).style.display = "block";
					
					document.getElementById('added_comment' + formid).innerHTML = xmlhttp.responseText;					
                      
					                          
					document.getElementById('comment_writing' + formid).innerHTML = '';
					document.getElementById('comment_directions' + formid).innerHTML = '<b>Thank you for your time.</b>';						  
					  				  


               }
    }
    //Make connection
    xmlhttp.open("POST", formhandler);
    //Set Headers
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    //Send data
    xmlhttp.send(formdata);
    //stops form from submitting normally
    }
    return false;
}


//--------------------------------------------------------------------------------------------------------------------------------------------
//ALAKERRAN POPUP-IKKUNAN JAVASCRIPTIT
//--------------------------------------------------------------------------------------------------------------------------------------------


var win=null;

function NewWindow(mypage,myname,w,h,scroll){

	{LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open("extras2.php?"+mypage,myname,settings);
	win.focus();
}

//--------------------------------------------------------------------------------------------------------------------------------------------
//WEB-camera POPUP-IKKUNAN JAVASCRIPTIT
//--------------------------------------------------------------------------------------------------------------------------------------------




function Camera(myname,w,h,scroll){
	
	{LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}

	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    win=window.open("camera.php",myname,settings);
    win.focus();
}


//--------------------------------------------------------------------------------------------------------------------------------------------
//blogi POPUP-IKKUNAN JAVASCRIPTIT
//--------------------------------------------------------------------------------------------------------------------------------------------


function blog(mypage,myname,w,h,scroll,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+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	    win=window.open(mypage,myname,settings);
	    win.focus();
}


//--------------------------------------------------------------------------------------------------------------------------------------------
//POPUP 2 JAVASCRIPTIT
//--------------------------------------------------------------------------------------------------------------------------------------------	


var arrTemp=self.location.href.split("?"); 
var picUrl = (arrTemp.length>0)?arrTemp[1]:""; 
var NS = (navigator.appName=="Netscape")?true:false;
	
function FitPic() { 		
	iWidth = (NS)?window.innerWidth:document.body.clientWidth; 
	iHeight = (NS)?window.innerHeight:document.body.clientHeight; 
	iWidth = document.images[0].width - iWidth; 
	iHeight = document.images[0].height - iHeight;
	window.resizeBy(iWidth, iHeight); 
	LeftPosition=(screen.width)?(screen.width-document.images[0].width)/2:100;
	TopPosition=(screen.height)?(screen.height-document.images[0].height)/2:100;		
	self.moveTo(LeftPosition, TopPosition); 		
	self.focus(); 
}



//--------------------------------------------------------------------------------------------------------------------------------------------
//YOUTUBE PLAYER
//--------------------------------------------------------------------------------------------------------------------------------------------	
		var params = { allowScriptAccess: "always" };
   		var atts = { id: "myytplayer" };
   		swfobject.embedSWF("http://www.youtube.com/v/or5mRjAOCsY&disablekb=1&showsearch=0&showinfo=0&iv_load_policy=3&rel=0&enablejsapi=1&playerapiid=ytplayer", 
                       "ytapiplayer", "1", "1", "8", null, null, params, atts);


		function onYouTubePlayerReady(playerId) {
      		ytplayer = document.getElementById("myytplayer");
			ytplayer.addEventListener("onStateChange", "onytplayerStateChange");      		
    	}	


			function play(tube, id) {

			tubeOld = null;
			if(ytplayer.getVideoUrl()) tubeOld = GetString(ytplayer.getVideoUrl(), "watch?v=", "&eurl");
				
			if (tubeOld == null || tubeOld == tube) {
			  	if (ytplayer.getPlayerState() != 1) {
				  	playerCount(id);
		    		ytplayer.loadVideoById(tube);
		    		ytplayer.unMute();
					ytplayer.setVolume(100);			  	
					document[tube].src="/pics/butterflying.gif";
					
				}else{

  					ytplayer.pauseVideo();
					ytplayer.seekTo(0);
					document[tube].src="/pics/butterfly.gif";
  				}
  			}else{
				playerCount(id);  			
	    		ytplayer.loadVideoById(tube);  			
	    		ytplayer.unMute();
				ytplayer.setVolume(100);			  	
				document[tube].src="/pics/butterflying.gif";
				document[tubeOld].src="/pics/butterfly.gif";				
				
  			}
		}
		
		
		function onytplayerStateChange(newState) {

			if(newState == 0) {
				tube = GetString(ytplayer.getVideoUrl(), "watch?v=", "&eurl");				
				document[tube].src="/pics/butterfly.gif";
			}
		}
		
		
		
		function trimAll(sString) {
		
			while (sString.substring(0,1) == ' '){
				sString = sString.substring(1, sString.length);}
			while (sString.substring(sString.length-1, sString.length) == ' '){
				sString = sString.substring(0,sString.length-1);}
			return sString;
			}
		
		function GetString(source, start, end){
			var st = source.indexOf(start) + start.length;
			var en = source.indexOf(end, start);
			var returnString = trimAll(source.substring(st, en));	
			return returnString;
		}


//--------------------------------------------------------------------------------------------------------------------------------------------
//PlayCount
//--------------------------------------------------------------------------------------------------------------------------------------------	

function playerCount(id){
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      }
    }
  xmlHttp.open("GET","/playerCount.php?id="+id+"",true);
  xmlHttp.send(null);
}
