var xmlhttp = null;

function orderby(obj){
	window.location.href = "http://" + jDomainURL + "/video/" + jcurrentpage + "/" + obj.options[obj.selectedIndex].value;
}
function sendsearch(){
	var mytag=document.search.tag.value;
	var mytag1=mytag.replace(/ /gi, "-");
	var mytag2=mytag1.toLowerCase();
	
	document.search.action="http://" + jDomainURL + "/" + jlangsearch + "/" + mytag2;
}

function changevideocat(){
	var mycat=videocat.options[videocat.selectedIndex].value
	if (mycat!=0){
		document.location.href="http://" + jDomainURL + "/video/" + mycat;
	}
}

function changephotocat(){

	var myphotocat=photocat.options[photocat.selectedIndex].value
	if (myphotocat!=0){
		document.location.href="http://" + jDomainURL + "/" + jlangphoto + "/" + myphotocat;
	}
}


function sndRating(strFile,strStars){
	var userIP = juserIP;
	var userSession = juserSession;
	var dvelement = document.getElementById('dv'+strFile);
    dvelement.innerHTML = "<img src='http://" + jDomainURL + "/static/" + jDomainID + "/templates/progressimgred.gif' alt='progress' />";
		var myData = "modo=sendRate&siteID=" + jSiteID + "&userSession=" + juserSession + "&strContent=" + strFile + "&StarsNr=" + strStars + "&userIP=" + juserIP;
	//alert(myData);
	startHttpReq(myData);
}


function startHttpReq(paramet){
    url = "http://" + jDomainURL + "/ajaxfunctions.asp";
    strData = paramet;
    if (document.getElementById) {
    	try { 
        	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
	    } catch (e) { 
    	    try { 
        	    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	        } catch (E) { 
    	        xmlhttp = false; 
        	} 
	    } 
	    if  (!xmlhttp && typeof  XMLHttpRequest != 'undefined' ) { 
    	    try  { 
        	    xmlhttp = new  XMLHttpRequest(); 
	        } catch  (e) { 
    	        xmlhttp = false ; 
        	} 
	    }
	    if (xmlhttp) {
    	    xmlhttp.onreadystatechange = XMLHttpRequestChange;
            xmlhttp.open("POST", url, true);
	        xmlhttp.setRequestHeader('Content-Type','text/xml');
    	    xmlhttp.setRequestHeader('encoding','ISO-8859-1');
    	    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded' ); 
            xmlhttp.setRequestHeader('Content-length', strData.length );
            xmlhttp.send(strData);
	    }
    }
}


function XMLHttpRequestChange() {
	//alert(xmlhttp.readyState + "-" + xmlhttp.status);
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
        var result = xmlhttp.responseText;
        
		var myResult_array=result.split(",");
		
		//*******************************************************
		if(myResult_array[0]=="sendRate"){
		//var drelement = document.getElementById('dv'+myResult_array[1]);
		var dvThanks = document.getElementById('dv'+myResult_array[1]);
		//drelement.style.display ='none';
  		//var rateThanks = jlangvotethanks;
  		dvThanks.innerHTML = jlangvotethanks;
		}
		// ------------------------------------------------------
    }
}



function hideDiv(d) {                   
		d.style.display = "none";
}               

function showDiv(d){
		d.style.display = "enable";
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}