

function OpenNewWindow(url, x, y) {
	var options = "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,width=" + x + ",height=" + y;
		msgWindow=window.open(url,"", options);
}

function OpenNewWindowNoScroll(url, x, y) {
	var options = "toolbar=no,menubar=no,scrollbars=no,resizable=yes,width=" + x + ",height=" + y;
		msgWindow=window.open(url,"", options);
}

/* -------------Player init, and move--------------*/ 

document.onmousedown=dragHandler;

function moveHandler(e){
      if (e == null) { e = window.event } 
      if (e.button<=1&&dragOK){
         savedTarget.style.left=e.clientX-dragXoffset+'px';
         savedTarget.style.top=e.clientY-dragYoffset+'px';
         return false;
      }
   }

   function cleanup(e) {
      document.onmousemove=null;
      document.onmouseup=null;
      savedTarget.style.cursor=orgCursor;
      dragOK=false;
   }

   function dragHandler(e){
      var htype='-moz-grabbing';
      if (e == null) { e = window.event; htype='move';} 
      var target = e.target != null ? e.target : e.srcElement;
      orgCursor=target.style.cursor;
      if (target.className=="popplayer") {
         savedTarget=target;       
         target.style.cursor=htype;
         dragOK=true;
         dragXoffset=e.clientX-parseInt(vidPaneID.style.left);
         dragYoffset=e.clientY-parseInt(vidPaneID.style.top);
         document.onmousemove=moveHandler;
         document.onmouseup=cleanup;
         return false;
      }
   }

/*dv = document.createElement('div');
dv.setAttribute('id',"css_dialog");
dv.style.cssText = "position:absolute;top:"+posY+"px;left:"+posX+"px;";*/

function getScreenCenterY() {
    var y = 0;
    y = getScrollOffset()+(getInnerHeight()/2);
    return(y);
}

function getScreenCenterX() {
    return(document.body.clientWidth/2);
}

function getInnerHeight() {
    var y;
    if (self.innerHeight) {// all except Explorer
        y = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {// Explorer 6 Strict Mode
        y = document.documentElement.clientHeight;
    } else if (document.body) {// other Explorers
        y = document.body.clientHeight;
    }
    return(y);
}

function getScrollOffset() {
    var y;
    if (self.pageYOffset) {// all except Explorer
        y = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {// Explorer 6 Strict
        y = document.documentElement.scrollTop;
    } else if (document.body) {// all other Explorers
        y = document.body.scrollTop;
    }
    return(y);
}
 
   
   
/* -----------------------------------------*/
function toBasket(id,quant,prod_type,album){
    //window.alert(id+ "  " +quant + " " + album); 
    if (album=='disc') {
        window.alert("The physical CD will be available after November 30th. Please check back then. Thank you for your patience and sorry for the inconvenience!"); 
    } else {
        var url = "to_basket.php?kosarhide=" + id + "&product" + id + "=" + quant + "&prod_type="+ prod_type + "&album=" + album;
        xmlHttp=GetXmlHttpObject(stateChanged);
        xmlHttp.open("GET", url , true);
        xmlHttp.send(null);   
    }
}

function fromBasket(id,prod_type,album){
    //window.alert(id+ "  " +quant);
    var url = "to_basket.php?kosartorol=" + id + "&prod_type="+ prod_type + "&album=" + album;
    xmlHttp=GetXmlHttpObject(stateChanged2);
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);
}

function playTrack(id,album){
    //window.alert(id+ "  " +album);
    var url = "player.php?track=" + id + "&album=" + album;
    xmlHttp=GetXmlHttpObject(stateChanged_PL);
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);
}

function stateChanged() { 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
        //window.alert(xmlHttp.responseText);
        if (xmlHttp.responseText == '-1') {
            window.alert('This item is already in the basket!'); 
        } else {
            document.getElementById('basket').innerHTML = xmlHttp.responseText;
            window.alert('This item has been placed in the basket!'); 
        }
    } 
} 

function stateChanged2() { 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
        var str=window.location.toString();
        if (str.match("pID=5") == "pID=5") window.location.reload();
        document.getElementById('basket').innerHTML = xmlHttp.responseText;
    }
}

function stateChanged_PL() { 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
        posY = getScreenCenterY();
        posX = getScreenCenterX();
        vidPaneID.style.top=(posY-300)+'px';                     // Starting location horozontal
        vidPaneID.style.left='300px';                    // Starting location verticle
       
        var s2 = new SWFObject("http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl=music/samples/"+ xmlHttp.responseText.split("#;#;")[1], "playlist", "350", "27", "7");
        s2.write("playa_pop");
        document.getElementById("txt_pop").innerHTML=xmlHttp.responseText.split("#;#;")[2];
        document.getElementById("pop_play").style.display='block';
    } 
}

function GetXmlHttpObject(handler)
{

    var objXmlHttp=null

    if (navigator.userAgent.indexOf("MSIE")>=0)
    { 
        var strName="Msxml2.XMLHTTP"
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP"
        } 
        try
        { 
            objXmlHttp=new ActiveXObject(strName)
            objXmlHttp.onreadystatechange=handler
            return objXmlHttp
        } 
        catch(e)
            { 
                alert("Error. Scripting for ActiveX might be disabled") 
                return 
            } 
    } 
    if (navigator.userAgent.indexOf("Mozilla")>=0 || navigator.userAgent.indexOf("Opera")>=0 || navigator.userAgent.indexOf("Safari")>=0)
    {
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler 
        return objXmlHttp
    }
}

function copyInvoiceAddress()
{
      document.getElementById('s_zip').value = document.getElementById('b_zip').value;
    document.getElementById('s_town').value = document.getElementById('b_town').value;
    document.getElementById('s_add').value = document.getElementById('b_add').value;
    document.getElementById('s_country').value = document.getElementById('b_country').value;
}

function checkReq() {
    var filter = /^.+@.+\..{2,6}$/;
    if (document.getElementById('req_ship').value == '0') {
        var kell = new Array('name','email');
    } else {
         var kell = new Array('name','email','s_country','s_zip','s_town','s_add');
    }
    
    var hiba = false;
    for(i=0;i<kell.length;i++) {
       if (document.getElementById(kell[i]).value=="") {
           document.getElementById(kell[i]).style.border= "2px red solid";
           hiba = true;
       } else {
             if (kell[i] == "email") {
                if (filter.test(document.getElementById(kell[i]).value)) {
                    document.getElementById(kell[i]).style.border= "1px black solid";
                } else {
                    window.alert("Wrong email format!");
                    document.getElementById(kell[i]).style.border= "2px red solid";
                    return false;
                }
             } else document.getElementById(kell[i]).style.border= "1px black solid";
       }
    }
    if (hiba == true) {
        window.alert("Please fill in the required fields!");
        return false;
    } else return true;
}

// --- ArtButt --- //

function artOver(id) {
    //window.alert(document.getElementById('artButt_left_'+id).className);
   document.getElementById('artButt_left_'+id).className= 'artButt_left_over';
   document.getElementById('artButt_right_'+id).className= 'artButt_right_over';
   document.getElementById('artButt_center_'+id).className= 'artButt_center_over';
   document.getElementById('tr_butt_'+id).className= 'transp_button_over';
}

function artOut(id) {
   document.getElementById('artButt_left_'+id).className= 'artButt_left';
   document.getElementById('artButt_right_'+id).className= 'artButt_right';
   document.getElementById('artButt_center_'+id).className= 'artButt_center';
   document.getElementById('tr_butt_'+id).className= 'transp_button';
}
 // -------------------------------- //
