var xmlHttp;

function makeCatActive(id) {
	document.getElementById(id).style.backgroundImage = 'url(img/category_frame_selected.gif)';
}

function makeCatDeactive(id) {
	document.getElementById(id).style.backgroundImage = 'url(img/category_frame.gif)';
}

function createRow(tableId,cellId)
{
	if ($(cellId)) {
		return false;
	}
	else {
		var lastRow = $(tableId).rows.length;
		var row = $(tableId).insertRow(lastRow);
		var cell = row.insertCell(0);
		cell.setAttribute('colSpan', '2');
		cell.setAttribute('style', 'color:#FF0000');
		cell.setAttribute('id', cellId);
		return true;
	}
}

function validateForm(fobj, ftbl, fmsg)
{
	
	var fl = "";
	for (var i = 0; i < fobj.length; i++)
	{
		for (var j = 1; j< fobj[i].length; j++)
		{ 
			if ($(fobj[i][j]['id']).value == ""){
				fl = fl + "<br />\n&nbsp;&bull;&nbsp;" + fobj[i][j]['label'] + "\n";
			}
		}
	}
	if (fl=="")
	{
		return true;
	} else {
		createRow(ftbl,'error_msg');
		$('error_msg').innerHTML = fmsg + ":\n\n" + fl;
		return false;
	}
}

function ValidateLang(vName, vLang, vMsg, vAbrErr){
    var FieldList = "";
    var validRegExp;
    
    if (document.getElementById("title").value == ""){
  	    FieldList = "<br />\n&nbsp;&bull;&nbsp;" + vName + "\n";
    }
	 if (document.getElementById("lang").value == ""){
  	    FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vLang + "\n";
    } else if (document.getElementById("lang").value.length != 2) {
		FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vAbrErr + "\n";
	}
      if (FieldList == ""){
        return ( true );
    } else {
        document.getElementById("error_msg").innerHTML = vMsg + ":\n\n" + FieldList;
        return( false );
    }
}

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

function ValidateLogin(vUsername, vPassword, vMsg)
{	
	var FieldList = "";
	
	if ($("c_username").value == "") {
        FieldList = "<br />\n&nbsp;&bull;&nbsp;"+vUsername+"\n";
    }
	if ($("c_userpass").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;"+vPassword+"\n";
    }
	if (FieldList == ""){
        return ( true );
    } else {
        $("error_msg").innerHTML = vMsg + ":\n\n" + FieldList;
        return( false );
    }
}

function ValidateSendFriend(vName, vEmail, vFriendName, vFriendEmail, vInvEmail, vMsg){
    var FieldList = "";
    //var validRegExp;
    //var strEmail;
    if ($("your_name").value == ""){
  	    FieldList = "<br />\n&nbsp;&bull;&nbsp;" + vName + "\n";
    }

	if ($("friends_name").value == ""){
  	    FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vFriendName + "\n";
    }
	
  validRegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/i;
    strEmail = $("your_mail").value;

    if ($("your_mail").value != "") {
        if (strEmail.search(validRegExp) == -1) {
            FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vInvEmail + "\n";
        }
    }
	
	validRegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/i;
    strEmail = $("friends_mail").value;

    if ($("friends_mail").value != "") {
        if (strEmail.search(validRegExp) == -1) {
            FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vInvEmail + "\n";
        }
    }
	
   if ($("your_mail").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vEmail + "\n";
    }
	
	if ($("friends_mail").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vFriendEmail + "\n";
    }
	
	
	
    if (FieldList == ""){
        return ( true );
    } else {
        $("error_msg").innerHTML = vMsg + ":\n\n" + FieldList;
        return( false );
    }
}

function ValidateSendCard(vName, vEmail, vFriendEmail, vInvEmail, vMsg){
    var FieldList = "";
    //var validRegExp;
    //var strEmail;
    if ($("your_name2").value == ""){
  	    FieldList = "<br />\n&nbsp;&bull;&nbsp;" + vName + "\n";
    }


	
  validRegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/i;
    strEmail = $("your_mail2").value;

    if ($("your_mail2").value != "") {
        if (strEmail.search(validRegExp) == -1) {
            FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vInvEmail + "\n";
        }
    }
	
	validRegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/i;
    strEmail = $("friends_mail2").value;

    if ($("friends_mail2").value != "") {
        if (strEmail.search(validRegExp) == -1) {
            FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vInvEmail + "\n";
        }
    }
	
   if ($("your_mail2").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vEmail + "\n";
    }
	
	if ($("friends_mail2").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vFriendEmail + "\n";
    }
	
	
	
    if (FieldList == ""){
        return ( true );
    } else {
        $("error_msg2").innerHTML = vMsg + ":\n\n" + FieldList;
        return( false );
    }
}

function ValidateContact(vName, vEmail, vPhone, vEnquiry, vInvEmail, vMsg){
    var FieldList = "";
    //var validRegExp;
    //var strEmail;
    if ($("c_name").value == ""){
  	    FieldList = "<br />\n&nbsp;&bull;&nbsp;" + vName + "\n";
    }
  validRegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/i;
    strEmail = $("c_email").value;

    if ($("c_email").value != "") {
        if (strEmail.search(validRegExp) == -1) {
            FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vInvEmail + "\n";
        }
    }
   if ($("c_email").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vEmail + "\n";
    }
	if ($("c_phone").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vPhone + "\n";
    }
	if ($("c_enquiry").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vEnquiry + "\n";
    }
    if (FieldList == ""){
        return ( true );
    } else {
        $("error_msg").innerHTML = vMsg + ":\n\n" + FieldList;
        return( false );
    }
}

function ValidateSignup ( vName, vUser, vEmail, vPhone, vCountry, vPostcode, vCity, vAddress, vInvEmail, vMsg, vPassword, vPassword2, vInvPassword, vSelectOne, vNotAgree){
    var FieldList = "";
    //var validRegExp;
    //var strEmail;
	
	
	


	
	 if ($("c_name").value == ""){
  	    FieldList = "<br />\n&nbsp;&bull;&nbsp;" + vName + "\n";
    }
	
    if ($("c_username").value == ""){
  	    FieldList = FieldList +"<br />\n&nbsp;&bull;&nbsp;" + vUser + "\n";
    }
	
	if ($("c_password").value == ""){
  	    FieldList = FieldList +"<br />\n&nbsp;&bull;&nbsp;" + vPassword + "\n";
    }
	
	if ($("c_password2").value == ""){
  	    FieldList = FieldList +"<br />\n&nbsp;&bull;&nbsp;" + vPassword2 + "\n";
    }
  validRegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/i;
    strEmail = $("c_email").value;

    if ($("c_email").value != "") {
        if (strEmail.search(validRegExp) == -1) {
            FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vInvEmail + "\n";
        }
    }
    if ($("c_email").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vEmail + "\n";
    }
	
	if ($("c_phone").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vPhone + "\n";
    }
	if ($("c_country").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vCountry + "\n";
    }
	if ($("c_postcode").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vPostcode + "\n";
    }
	if ($("c_city").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vCity + "\n";
    }
	if ($("c_address").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vAddress + "\n";
    }
	
	if ($("c_password").value != $("c_password2").value){
		FieldList = FieldList + "<br />\n" + vInvPassword + "\n";
	}
	
	var t=0;
	var c=document.c_form['c_goal[]'];
	for(var i=0;i<c.length;i++){
	c[i].checked?t++:null;
	}
	if(t < 1){
		FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vSelectOne + "\n";
	}
	
	if (document.getElementById("i_agree").checked==false){
		FieldList = FieldList + "<br />\n" + vNotAgree + "\n";
	}
	
    if (FieldList == ""){
        return ( true );
    } else {
        $("error_msg").innerHTML = vMsg + ":\n\n" + FieldList;
        return( false );
    }
}

function ValidateProfile ( vName, vPass, vPass2, vEmail, vPhone, vCountry, vPostcode, vCity, vAddress, vInvEmail, vInvMatch, vMsg){
    var FieldList = "";
    //var validRegExp;
    //var strEmail;
	 if ($("c_name").value == ""){
  	    FieldList = "<br />\n&nbsp;&bull;&nbsp;" + vName + "\n";
    }
		
	 if (($("c_password").value != "") || ($("c_password2").value != "")) {
		 if ($("c_password").value != $("c_password2").value) {
			 FieldList = FieldList +"<br />\n&nbsp;&bull;&nbsp;"+ vPass2 +"&nbsp;"+ vInvMatch +"&nbsp;"+ vPass+ "\n";
		 }
	 }
	 
  validRegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/i;
    strEmail = $("c_email").value;

    if ($("c_email").value != "") {
        if (strEmail.search(validRegExp) == -1) {
            FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vInvEmail + "\n";
        }
    }
    if ($("c_email").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vEmail + "\n";
    }
	if ($("c_phone").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vPhone + "\n";
    }
	if ($("c_country").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vCountry + "\n";
    }
	if ($("c_postcode").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vPostcode + "\n";
    }
	if ($("c_city").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vCity + "\n";
    }

	if ($("c_address").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vAddress + "\n";
    }
    if (FieldList == ""){
        return ( true );
    } else {
        $("error_msg").innerHTML = vMsg + ":\n\n" + FieldList;
        return( false );
    }
}

function ValidateCheckout(vName,  vEmail, vPhone, vPostcode, vCity, vCountry, vInvNote, vInvEmail, vMsg){
    var FieldList = "";
    var validRegExp;
    var strEmail;
    if ($("co_name").value == ""){
  	    FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vName + "\n";
    }
 	
    validRegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/i;
    strEmail = $("co_email").value;

    if ($("co_email").value != "") {
        if (strEmail.search(validRegExp) == -1) {
            FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vInvEmail + "\n";
        }
    }
    if ($("co_email").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vEmail + "\n";
    }
	if ($("co_phone").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vPhone + "\n";
    }
	if ($("co_postcode").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vPostcode + "\n";
    }
	if ($("co_city").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vCity + "\n";
    }	
	if ($("co_country").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vCountry + "\n";
    }
	if ($("co_note").value.length > 300) {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vInvNote + "\n";
    }
    if (FieldList == ""){
        return ( true );
    } else {
        $("error_msg").innerHTML = vMsg + ":\n\n" + FieldList;
        return( false );
    }
}

function ValidateComment(vName, vEmail, vAbout, vComment, vInvEmail, vMsg){
    var FieldList = "";
    var validRegExp;
    var strEmail;
    if ($("cm_name").value == ""){
  	    FieldList = "<br />\n&nbsp;&bull;&nbsp;" + vName + "\n";
    }
  validRegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/i;
    strEmail = $("cm_email").value;

    if ($("cm_email").value != "") {
        if (strEmail.search(validRegExp) == -1) {
            FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vInvEmail + "\n";
        }
    }
    if ($("cm_email").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vEmail + "\n";
    }

	if ($("cm_about").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vAbout + "\n";
    }
	if ($("cm_comment").value == "") {
        FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + vComment + "\n";
    }
    if (FieldList == ""){
        return ( true );
    } else {
        $("error_msg").innerHTML = vMsg + ":\n\n" + FieldList;
        return( false );
    }
}

function ValidateProduct(idArr){
    var FieldList = "";
    if ($("category_hash").value == "") {
        FieldList = "<br />\n&nbsp;&bull;&nbsp;Category\n";
    }
	for (var i = 0; i < idArr.length; i++)
	{
	    if ($(idArr[i]).value == "") {
            FieldList = FieldList + "<br />\n&nbsp;&bull;&nbsp;" + idArr[i] + "\n";
        }	
	}
    if (FieldList == ""){
        return ( true );
    } else {
        $("error_msg").innerHTML = "Please complete next fields:\n\n" + FieldList;
        return( false );
    }
}

function delItemById(controller, pid) {
    var answer = confirm("Are you sure you want to delete selected record?");
	if (answer) {
        window.location = "index.php?controller=" + controller + "&action=delete&id=" + parseInt(pid);
		return false;
	}
}

function delItemById2(controller, action, pid) {
    var answer = confirm("Are you sure you want to delete selected record?");
	if (answer) {
        window.location = "index.php?controller=" + controller + "&action=" + action + "&id=" + parseInt(pid);
		return false;
	}
}

function sendNewslttr(controller, pid) {
    var answer = confirm("Are you sure you want to send this newsletter?");
	if (answer) {
        window.location = "index.php?controller=" + controller + "&action=send&id=" + pid;
		return false;
	}
}

function delItem(controller, pHash, myAction, parent_hash) {
    var answer = confirm("Are you sure you want to delete selected record?");
	var dAction = (typeof myAction == "undefined") ? "delete" : myAction;
	var dParentHash = (typeof parent_hash == "undefined") ? "" : "&parent_hash=" + parent_hash;
	
	if(controller=="languages" && answer) 
		answer = confirm("If you delete a language, all pages, products and categories\n related to that language will be deleted too!\n Are you sure you want to continue?");
	if (answer) {
        window.location = "index.php?controller=" + controller + "&action=" + dAction + "&hash=" + pHash + dParentHash;
		return false;
	}
}

function delCustomers(controller, pid) {
    var answer = confirm("The customer will be deleted!\n Are you sure you want to delete the user?");
	if (answer) {
        window.location = "index.php?controller=" + controller + "&action=delete&id=" + pid;
		return false;
	}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function changeParents(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return false;
  } 
var url="changeParents.php";
lang_id= str.options[str.selectedIndex].value;
url=url+"?lang_id="+lang_id;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

}

function stateChanged() 
{ 
    if (xmlHttp.readyState==4 && xmlHttp.status==200)
    {
	    //alert(xmlHttp.responseText);
	    $("par_id").innerHTML=xmlHttp.responseText;
    }
}

function delNewsPic(state,new_id,pic)
{

	if(state==1) $('del'+pic).style.visibility="visible";
	if(state==0) $('del'+pic).style.visibility="hidden";
	if(state==2)
	{
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return false;
		} 
		var url="delNewsPic.php";
		url=url+"?pic="+pic;
		url=url+"&new="+new_id;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=stateChanged1;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);

	}
}
function stateChanged1() 
{ 
if (xmlHttp.readyState==4 && xmlHttp.status==200)
{
	$("pic_holder"+xmlHttp.responseText).innerHTML='<img src="../img/addpic.jpg" class="cms_news_pics"/><br/><br/><input type="file" size="10" name="pic'+xmlHttp.responseText+'" id="pic'+xmlHttp.responseText+'">';
}
}
function moveMe(direction,table,containerID,theHash,subHash)
{
	http = GetXmlHttpObject();
    var url = "move_me.php";
	var myRandom = parseInt(Math.random()*99999999);
	var mySubHash = (typeof subHash == 'undefined') ? '' : "&sub_hash=" + subHash;
	http.open("GET", url + "?direction=" + direction + "&table=" + table + "&hash=" + theHash + mySubHash + "&rand=" + myRandom, true); 
	http.onreadystatechange = function () {handleMoveMe(containerID)};
	http.send(null);
}
function handleMoveMe (containerID) {
	if (http.readyState == 4) { 
        if (http.status == 200) {
			$(containerID).innerHTML = http.responseText;
		}
	} else {
			$(containerID).innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}
function clearBox(boxID)
{
	if ($(boxID))
	{
	    $(boxID).innerHTML = '';
    }
}

var toggle = {
	show : function() {
		for ( i=0; i < arguments.length; i++ ) {
			$(arguments[i]).style.display = '';
		}
	},
	hide : function() {
		for ( i=0; i < arguments.length; i++ ) {
			$(arguments[i]).style.display = 'none';
		}
	},
	switchOver : function() {
		for ( i=0; i < arguments.length; i++ ) {
			if ($(arguments[i]).style.display != 'none'){
				$(arguments[i]).style.display = 'none'
			} else {
				$(arguments[i]).style.display = ''
			}
		}
	}
};



function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        return false;
    }
    return true;
}
function isFloatKeyOriginal(evt) {
    var charCode = (evt.which) ? evt.which : evt.keyCode
	if (charCode != 46 && (charCode < 48 || charCode > 57)) {
		return false;
	}
    return true;
}

function isFloatKey(evt) {
    var charCode = (evt.which) ? evt.which : evt.keyCode
	if (charCode != 45 && charCode != 46 && charCode != 8 && charCode != 99  && charCode != 118  && (charCode < 48 || charCode > 57)) {
		return false;
	}
    return true;
}
function calcPrice(e,rownum) {
	var dPrice = parseFloat($(e).value);
	for (var i = 0; i < theArray.length; i++){
		var id = "price_" + theArray[i][4] + "_" + parseInt(rownum);
		var val = theArray[i][3] * dPrice;		
		if (!(val)) {			
			$(id).value = "0.00";
		}
		else {
			$(id).value = val.toFixed(2);
		}  
	}
}
function logo_delete(hash)
{
    jsmx.onWait = function(){ $('loading_box').style.display = 'inline'; }
    jsmx.onWaitEnd = function(){ $('loading_box').style.display = 'none'; }
	var params = 'hash='+hash;
	http('GET', 'del_logo.php', logo_callback, params);
}

function updateRate(i, id, did, fid) {
	//alert (i + id + did + fid);
	var quantity = $("quantity_" + i).value;
	var rate = $("rate_" + i).value;
	http4 = GetXmlHttpObject();
    var url = "update_rate.php";
	var myRandom = parseInt(Math.random()*99999999);
	http4.open("GET", url + "?id=" + id + "&did=" + did + "&fid=" + fid + "&quantity=" + quantity + "&rate=" + rate + "&rand=" + myRandom, true); 
	http4.onreadystatechange = handleupdateRate;
	http4.send(null);
}
function handleupdateRate () {
	if (http4.readyState == 4) { 
        if (http4.status == 200) {
			$("exchangesBox").innerHTML = http4.responseText;
		}
	} else {
			$("exchangesBox").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}
function delArticle(product_hash, article_hash) {
	http4 = GetXmlHttpObject();
    var url = "del_article.php";
	var myRandom = parseInt(Math.random()*99999999);
	http4.open("GET", url + "?product_hash=" + product_hash + "&article_hash=" + article_hash + "&rand=" + myRandom, true); 
	http4.onreadystatechange = handleDelArticle;
	http4.send(null);
}
function handleDelArticle () {
	if (http4.readyState == 4) { 
        if (http4.status == 200) {
			$("articleBox").innerHTML = http4.responseText;
		}
	} else {
			$("articleBox").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}
function delPicture(product_hash, picture_id) {
	http3 = GetXmlHttpObject();
    var url = "del_picture.php";
	var myRandom = parseInt(Math.random()*99999999);
	http3.open("GET", url + "?product_hash=" + product_hash + "&picture_id=" + parseInt(picture_id) + "&rand=" + myRandom, true); 
	http3.onreadystatechange = handleDelPicture;
	http3.send(null);
}

function handleDelPicture () {
	if (http3.readyState == 4) { 
        if (http3.status == 200) {
			$("pictureBox").innerHTML = http3.responseText;
		}
	} else {
			$("pictureBox").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}


function delCat(hash, pic) {
	http3 = GetXmlHttpObject();
    var url = "del_cat.php";	
	http3.open("GET", url + "?hash=" + hash + "&pic=" + pic, true); 
	http3.onreadystatechange = handleDelCat;
	http3.send(null);
}


function handleDelCat () {
	if (http3.readyState == 4) { 
        if (http3.status == 200) {
			document.getElementById("pictureBox2").innerHTML = http3.responseText;
		}
	} else {
			document.getElementById("pictureBox2").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}

function delNewsletterClient(id, session) {
	http3 = GetXmlHttpObject();
    var url = "del_newsletter_client.php";
	var myRandom = parseInt(Math.random()*99999999);
	http3.open("GET", url + "?id=" + parseInt(id) + "&session=" + session, true); 
	http3.onreadystatechange = handleDelNewsletterClient;
	http3.send(null);
}


function handleDelNewsletterClient () {
	if (http3.readyState == 4) { 
        if (http3.status == 200) {
			document.getElementById("clientBox").innerHTML = http3.responseText;
		}
	} else {
			document.getElementById("clientBox").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}

function delSimilarProduct(product_hash, similar_hash) {
	http6 = GetXmlHttpObject();
    var url = "del_similar_product.php";
	var myRandom = parseInt(Math.random()*99999999);
	http6.open("GET", url + "?product_hash=" + product_hash + "&similar_hash=" + similar_hash, true); 
	http6.onreadystatechange = handleDelSimilarProduct;
	http6.send(null);
}


function handleDelSimilarProduct () {
	if (http6.readyState == 4) { 
        if (http6.status == 200) {
			document.getElementById("similarBox").innerHTML = http6.responseText;
		}
	} else {
			document.getElementById("similarBox").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}

function delNewsletterPd(id, session) {
	http3 = GetXmlHttpObject();
    var url = "del_newsletter_pd.php";
	var myRandom = parseInt(Math.random()*99999999);
	http3.open("GET", url + "?id=" + parseInt(id) + "&session=" + session, true); 
	http3.onreadystatechange = handleDelNewsletterProduct;
	http3.send(null);
}


function handleDelNewsletterProduct () {
	if (http3.readyState == 4) { 
        if (http3.status == 200) {
			document.getElementById("productBox").innerHTML = http3.responseText;
		}
	} else {
			document.getElementById("productBox").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}

function getDiscount(id) {	
	http3 = GetXmlHttpObject();
    var url = "get_discount.php";	
	http3.open("GET", url + "?id=" + parseInt(id), true); 
	http3.onreadystatechange = handlegetDiscount;
	http3.send(null);

}


function handlegetDiscount () {
	if (http3.readyState == 4) { 
        if (http3.status == 200) {
			//document.getElementById("cl_discount").innerHTML = http3.responseText;
			document.getElementById("cl_info").innerHTML = http3.responseText;			
		}
	} else {
			document.getElementById("cl_info").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}

function delOrderCreate(id, session) {
	http3 = GetXmlHttpObject();
    var url = "del_order_create.php";
	var myRandom = parseInt(Math.random()*99999999);
	http3.open("GET", url + "?id=" + parseInt(id) + "&session=" + session, true); 
	http3.onreadystatechange = handledelOrderCreate;
	http3.send(null);
}


function handledelOrderCreate () {
	if (http3.readyState == 4) { 
        if (http3.status == 200) {
			document.getElementById("productBox").innerHTML = http3.responseText;
		}
	} else {
			document.getElementById("productBox").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}

function getTotal(e,price) {
	var total = 0;
	for (var i = 0; i < document.article_form.elements.length/2; i++)
	{
	    var price_id = 'pr_' + i;
		var quantity_id = "num_" + i;
		var price = $(price_id).value;
		var q = $(quantity_id);
		var quantity = q.options[q.selectedIndex].value;
		
		if (quantity == "")
		{
			quantity = 0;
		}
		
		total += parseFloat(price) * parseInt(quantity);
	}
	$('total').innerHTML = total.toFixed(2);
}
function bigimage(image,title,wid,hgt){
sw=(screen.width-wid)/2;
sh=(screen.height-hgt)/2;
newwin=window.open('','newwin','width='+wid+',height='+hgt+',scrollbars=1,resizable=1,menubar=0,toolbar=0,location=0,directories=0,status=0,top='+sh+',left='+sw+'');
newwin.document.open();
newwin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n');
newwin.document.write('"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
newwin.document.write('\n<html>\n<head>\n');
newwin.document.write('<title>'+title+'</title>\n');
newwin.document.write('</head>');
//newwin.document.write('<body style="margin:0;padding:0">\n<img src="'+image+'" width="'+wid+'" height="'+hgt+'" />');
newwin.document.write('<body style="margin:0;padding:0">\n<img src="'+image+'" alt="" />');
newwin.document.write('\n</body></html>');
newwin.document.close();
newwin.focus();
}
function bigpic(file,wid,hgt){
	sw=(screen.width-wid)/2;
    sh=(screen.height-hgt)/2;
	window.open(file,'mywindow','width='+wid+',height='+hgt+',scrollbars=1,resizable=1,menubar=0,toolbar=0,location=0,directories=0,status=0,top='+sh+',left='+sw+'')
}
//Shopping cart
function checkout_cart(base_href)
{
	jsmx.onWait = function(){ $('loading_checkout').style.display = 'inline'; }
    jsmx.onWaitEnd = function(){ $('loading_checkout').style.display = 'none'; }
	var handling = $('handling').value;
	var wrapping = $('wrapping').value;
	var params = 'section=cart&action=checkout&handling=' + parseFloat(handling) + '&wrapping=' + parseFloat(wrapping);
	http('GET', base_href + 'ajax.php', checkout_callback, params);
}
function checkout_callback(r)
{ 
	$('checkout_cart').innerHTML = r;
}
function update_preview(base_href)
{	
	var jm=new jsmxConstructor();	
	jm.onWait = function(){ $('loading_preview').style.display = 'inline'; $('cart_preview').innerHTML = '';}
    jm.onWaitEnd = function(){ $('loading_preview').style.display = 'none'; }
	var par = 'section=cart&action=preview';
	http('GET', base_href+'ajax.php', preview_callback, par);	
}

function preview_callback(rs)
{
	$('cart_preview').innerHTML =  decodeURIComponent(rs);
}

function add_items(num,minimal,pd,base_href,vMsg)
{
	var j=new jsmxConstructor();
	var err = 0;
	for (i = 0;i < num.length;i++)
	   {
			var qty = eval($('qty_' + num[i]).innerHTML);
			if(qty<minimal[i] && qty!=0){
				err = 1;
			}
	   }
	   
	if(err == 1){
		$('errmsg').innerHTML = vMsg;
		return false;
	} else {
		$('errmsg').innerHTML = '';
	}
	
	 for (i = 0;i < num.length;i++)
	   {		  
			j.onWait = function(){ $('loading_'+pd).style.display = 'inline'; }
			j.onWaitEnd = function(){ $('loading_'+pd).style.display = 'none'; }	
			var id = 'article_' + num[i];
			var qty = $('qty_' + num[i]).innerHTML;
			
			var callback = function(obj){ 
				add_callback(obj, base_href);
			}
		
			 if ( parseInt(qty)){		 
				var hash = $(id).innerHTML;
				var pms = 'section=cart&action=add&hash='+hash+'&qty='+qty;
				document.rowNum = pd;
				http('GET', base_href+'ajax.php', callback, pms);				
			} 
	  }	
	  //alert(i);
	 // update_preview();
}

function add_callback(result, base_href)
{
	$('status_'+document.rowNum).innerHTML = decodeURIComponent(result);
	 update_preview(base_href);
}

function remove_item(id, base_href)
{
	jsmx.onWait = function(){ $('loading_'+id).style.display = 'inline'; }
    jsmx.onWaitEnd = function(){ $('loading_'+id).style.display = 'none'; }
	var params = 'section=cart&action=remove&id='+parseInt(id);
	http('GET', base_href+'ajax.php', remove_callback, params);
}

function remove_callback(result)
{	
	$('cartBox').innerHTML = decodeURIComponent(result);	
}

function empty_cart(base_href)
{
	jsmx.onWait = function(){ $('loading_box').style.display = 'inline'; }
    jsmx.onWaitEnd = function(){ $('loading_box').style.display = 'none'; }
	var params = 'section=cart&action=empty';
	http('GET', base_href + 'ajax.php', empty_callback, params);
}

function empty_callback(result)
{
	$('cartBox').innerHTML = decodeURIComponent(result);
}

function update_cart(base_href)
{
	//var js=new jsmxConstructor();
	jsmx.onWait = function(){ $('loading_box').style.display = 'inline'; }
    jsmx.onWaitEnd = function(){ $('loading_box').style.display = 'none'; }
	var url = 'section=cart&action=update';
	var params = url + '&' + getFormValues($('cart_form'));
	//alert(params);
	http('GET', base_href + 'ajax.php', update_callback, params);
}

function update_callback(reslt)
{
	//alert(reslt);
	$('cartBox').innerHTML = reslt;
}

function change_article(e,num){
	var hash = e.options[e.selectedIndex].value;
	var article = 'article_' + num;
	var price = 'price_' + num;
	var prArr = 'prArr_' + num + "['" + hash + "']";
	$(article).innerHTML = hash;
	$(price).innerHTML = currency_sign + ' ' + (eval(prArr)).toFixed(2);
}
function change_qty(e,num)
{
	var q = e.options[e.selectedIndex].value;
	var qty = 'qty_' + num;
	$(qty).innerHTML = q;
}

function change_qty_input(num)
{
	var q = $("q_"+num).value;
	var qty = 'qty_' + num;
	$(qty).innerHTML = q;
}
function getFormValues(fobj){
    var str='';
    for(var i=0;i< fobj.elements.length;i++){
        str+=fobj.elements[i].name+'='+ encodeURIComponent(fobj.elements[i].value)+'&';
    }
    str=str.substr(0,(str.length-1));
    return str;
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	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 eraseCookie(name) {
	createCookie(name,"",-1);
}

function number_format( number, decimals, dec_point, thousands_sep ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://crestidg.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)    
    // *     example 1: number_format(1234.5678, 2, '.', '');
    // *     returns 1: 1234.57     
 
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "," : dec_point;
    var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}
////////////////////////////////////////////////////////
function dynamicSelect(id1, id2) {
	// Browser and feature tests to see if there is enough W3C DOM support
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_mac = (agt.indexOf("mac") != -1);
	if (!(is_ie && is_mac) && document.getElementById && document.getElementsByTagName) {
		// Obtain references to both select boxes
		var sel1 = document.getElementById(id1);
		var sel2 = document.getElementById(id2);
		// Clone the dynamic select box
		var clone = sel2.cloneNode(true);
		// Obtain references to all cloned options 
		var clonedOptions = clone.getElementsByTagName("option");
		// Onload init: call a generic function to display the related options in the dynamic select box
		refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
		// Onchange of the main select box: call a generic function to display the related options in the dynamic select box
		sel1.onchange = function() {
			refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
		};
	}
}
function refreshDynamicSelectOptions(sel1, sel2, clonedOptions) {
	// Delete all options of the dynamic select box
	while (sel2.options.length) {
		sel2.remove(0);
	}
	// Create regular expression objects for "select" and the value of the selected option of the main select box as class names
	var pattern1 = /( |^)(select)( |$)/;
	var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");
	// Iterate through all cloned options
	for (var i = 0; i < clonedOptions.length; i++) {
		// If the classname of a cloned option either equals "select" or equals the value of the selected option of the main select box
		if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {
			// Clone the option from the hidden option pool and append it to the dynamic select box
			sel2.appendChild(clonedOptions[i].cloneNode(true));
		}
	}
}

 function outputSelected2(opt, product_hash) {
			http3 = GetXmlHttpObject();
			var url = "add_similar.php";
			var myRandom = parseInt(Math.random()*99999999);
            var sel = getSelected(opt);
            var strSel = "";
            for (var item in sel)       
               strSel += sel[item].value + "<br>";
            //alert("Selected Items:\n" + strSel);
			if (strSel == ""){
				return ( true );
			} else {
				http3.open("GET", url + "?product_hash=" + product_hash + "&opt=" + strSel , true); 
				http3.onreadystatechange = handleAddSimilar;
				http3.send(null);
				return( false );
			}
         }


function handleAddSimilar () {
	if (http3.readyState == 4) { 
        if (http3.status == 200) {
			document.getElementById("similarBox").innerHTML = http3.responseText;
		}
	} else {
			document.getElementById("similarBox").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}

//////////////////////////////////////
function getSelected(opt) {
            var selected = new Array();
            var index = 0;
            for (var intLoop = 0; intLoop < opt.length; intLoop++) {
               if ((opt[intLoop].selected) ||
                   (opt[intLoop].checked)) {
                  index = selected.length;
                  selected[index] = new Object;
                  selected[index].value = opt[intLoop].value;
                  selected[index].index = intLoop;
               }
            }
            return selected;
         }

         function outputSelected(opt, session) {
			http3 = GetXmlHttpObject();
			var url = "add_client_newsletter.php";
			var myRandom = parseInt(Math.random()*99999999);
            var sel = getSelected(opt);
            var strSel = "";
            for (var item in sel)       
               strSel += sel[item].value + "<br>";
            //alert("Selected Items:\n" + strSel);
			if (strSel == ""){
				return ( true );
			} else {
				//$('clientBox').innerHTML = strSel;
				http3.open("GET", url + "?session=" + session + "&opt=" + strSel , true); 
				http3.onreadystatechange = handleAddNewsletter;
				http3.send(null);
				return( false );
			}
         }


function handleAddNewsletter () {
	if (http3.readyState == 4) { 
        if (http3.status == 200) {
			document.getElementById("clientBox").innerHTML = http3.responseText;
		}
	} else {
			document.getElementById("clientBox").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}


function AddPd2Newsletter(opt, session)
{
	http7 = GetXmlHttpObject();
    var url = "add_pd_newsletter.php";
	var sel = getSelected(opt);
    var strSel = "";
    for (var item in sel)       
    strSel = sel[item].value;
     //alert("Selected Items:\n" + strSel);
	if (strSel == ""){
		return ( true );
	} else {
	http7.open("GET", url + "?session=" + session + "&article_hash=" +  strSel , true); 
	http7.onreadystatechange = handleAddPd2Newsletter;
	http7.send(null);
	}	
}

function UpdatePdNewsletter (n, session) {	
		var arr_id 		  = "";
		var arr_new_price = "";	
		
		http7 = GetXmlHttpObject();
		var url = "update_pd_newsletter.php";
		
		for(var i=1;i < n; i++) {			
			arr_id 			+= document.getElementById('id_'+ i).value + "<br>";
			arr_new_price 	+= document.getElementById('new_price_'+ i).value + "<br>";		
		}		
		http7.open("GET", url + "?session=" + session + "&arr_id=" + arr_id + "&arr_new_price=" + arr_new_price , true); 
		http7.onreadystatechange = handleAddPd2Newsletter;
		http7.send(null);		
}

function handleAddPd2Newsletter () {
	if (http7.readyState == 4) { 
        if (http7.status == 200) {
			document.getElementById("productBox").innerHTML = http7.responseText;
		}
	} else {
			document.getElementById("productBox").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}

function updateClients () {	
		var arr_id 		  = "";
		var arr_new_price = "";	
		
		http12 = GetXmlHttpObject();
		var url = "update_newsletter_clients.php";
		q = document.getElementById("q").value;
		active = document.getElementById("active").value;
		counter = document.getElementById("counter").value;
		count_orders = document.getElementById("count_orders").value;
		arrange = document.getElementById("arrange").value;
		q_city = document.getElementById("q_city").value;
		q_country = document.getElementById("q_country").value;
		q_discount = document.getElementById("q_discount").value;
		q_goal = document.getElementById("q_goal").value;
		data_from = document.getElementById("data_from").value;
		data_to = document.getElementById("data_to").value;
		orderbydate = document.getElementById("orderbydate").value;
		http12.open("GET", url + "?q="+q+"&active="+active+"&counter="+counter+"&count_orders="+count_orders+"&arrange="+arrange+"&q_city="+q_city+"&q_country="+q_country+"&q_discount="+q_discount+"&q_goal="+q_goal+"&data_from="+data_from+"&data_to="+data_to+"&orderbydate="+orderbydate, true); 
		http12.onreadystatechange = handleUpdateClients;
		http12.send(null);		
}

function updateProducts () {	
		var arr_id 		  = "";
		var arr_new_price = "";	
		
		http12 = GetXmlHttpObject();
		var url = "update_similar_products.php";
		q = document.getElementById("q").value;
		active = document.getElementById("active").value;
		city_id = document.getElementById("city_id").value;
		category_hash = document.getElementById("category_hash").value;
		promo = document.getElementById("promo").value;
		novo = document.getElementById("new").value;
		http12.open("GET", url + "?q="+q+"&active="+active+"&city_id="+city_id+"&category_hash="+category_hash+"&promo="+promo+"&new="+novo, true); 
		http12.onreadystatechange = handleUpdateProducts;
		http12.send(null);		
}

function handleUpdateClients () {
	if (http12.readyState == 4) { 
        if (http12.status == 200) {
			document.getElementById("clients").innerHTML = http12.responseText;
		}
	} else {
			document.getElementById("clients").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}

function handleUpdateProducts () {
	if (http12.readyState == 4) { 
        if (http12.status == 200) {
			document.getElementById("similar_products").innerHTML = http12.responseText;
		}
	} else {
			document.getElementById("similar_products").innerHTML = "<img src=\"../img/ajax_24.gif\" style=\"border:none;width:24px;height:24px;\" alt=\"\" />\n";
	}
}

function submit_form(){
	document.getElementById("unregistered_emails").value  = document.newsletterform2.unreg_emails.value;
	document.newsletterform.submit();
}

function shows (id){
	if (document.getElementById("c_goal").checked==true){
		$(id).style.display = 'inline'; 
	} else {
		 $(id).style.display = 'none'; 
	}
}

function shows2 (id){
	$(id).style.display = 'block'; 
}
	
function hides (id){	
	if (document.getElementById("c_goal").checked==false){
	 $(id).style.display = 'none'; 
	 }
}	

function addfakturabg(){
	if (document.getElementById("checkboxbg").checked==true){
		document.getElementById('f_bulstat').value = 'BG'+document.getElementById('f_bulstat').value;
	} else {
		document.getElementById('f_bulstat').value = document.getElementById('f_bulstat').value.replace("BG", "");
	}
}
function rateImg(rating,picHash){


aj = new createAjax();
aj.onreadystatechange=function(){
	if(aj.readyState==4)
		  {
			var responsetext = aj.responseText.split("^");
			document.getElementById('current-rating_'+picHash).style.width = responsetext[2]+'px';  
		  	document.getElementById('rating_result_'+picHash).innerHTML = responsetext[0]; 
		  	document.getElementById('votes_result_'+picHash).innerHTML = responsetext[1]; 
		  }
	}
    var url = "cms/update_vote.php?rating="+rating+"&picHash="+picHash+"&sid="+Math.random();
	aj.open("GET",url,true);
	aj.send(null);	
}

function votesOrderBy(criteria, page, language, special){

aj = new createAjax();
aj.onreadystatechange=function(){
	if(aj.readyState==4)
		  {
			var responsetext = aj.responseText;
			if(criteria=='date'){
			document.getElementById('date').style.fontWeight = 'bold';
			document.getElementById('date').style.textDecoration = 'underline';
			document.getElementById('rating').style.fontWeight = 'normal';
			document.getElementById('rating').style.textDecoration = 'none';
			} else {
			document.getElementById('date').style.fontWeight = 'normal';
			document.getElementById('date').style.textDecoration = 'none';
			document.getElementById('rating').style.fontWeight = 'bold';
			document.getElementById('rating').style.textDecoration = 'underline';
			}
			document.getElementById('allvotes').innerHTML = responsetext;  
		  }
	}
	if(special==3){
		var url = "cms/order_vote_client.php?criteria="+criteria+"&page="+page+"&language="+language+"&special="+special+"&sid="+Math.random();
	} else {
		var url = "cms/order_vote.php?criteria="+criteria+"&page="+page+"&language="+language+"&special="+special+"&sid="+Math.random();
	}
	aj.open("GET",url,true);
	aj.send(null);	


}

function votesOrderClientBy(criteria, page, language, special, page_id, page_parent_id, page_hash){

aj = new createAjax();
aj.onreadystatechange=function(){
	if(aj.readyState==4)
		  {
			var responsetext = aj.responseText;
			if(criteria=='date'){
			document.getElementById('date').style.fontWeight = 'bold';
			document.getElementById('date').style.textDecoration = 'underline';
			document.getElementById('rating').style.fontWeight = 'normal';
			document.getElementById('rating').style.textDecoration = 'none';
			} else {
			document.getElementById('date').style.fontWeight = 'normal';
			document.getElementById('date').style.textDecoration = 'none';
			document.getElementById('rating').style.fontWeight = 'bold';
			document.getElementById('rating').style.textDecoration = 'underline';
			}
			document.getElementById('allvotes').innerHTML = responsetext;  
		  }
	}
	var url = "cms/order_vote_client.php?criteria="+criteria+"&page="+page+"&language="+language+"&special="+special+"&page_id="+page_id+"&page_parent_id="+page_parent_id+"&page_hash="+page_hash+"&sid="+Math.random();
	aj.open("GET",url,true);
	aj.send(null);	


}

function createAjax(){
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
	    aj = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else 
	 if (window.ActiveXObject)   // ActiveX version
	 {
	   aj = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	 } 
	return aj;
}




function toggle_show(box) {
   document.getElementById(box).style.display = 'block';
    return true;
}
function toggle_hide(box) {
   document.getElementById(box).style.display = 'none';
    return true;
}
