function ChangeQueryAndSubmit(ddName)
{
    var url = window.location.toString();
    var pnOld = '';
    var pnNew = '';
    
    url.match(/\?(.+)$/);
    var params = RegExp.$1;
    var params = params.split("&");
    var ppValue = '';
    
    for(var i=0;i<params.length;i++)
    {
 	    var tmp = params[i].split("=");
 	    if (tmp[0] == ddName) 
 	            ppValue = tmp[1];
 	    else
 	    {
 	        if (tmp[0] == 'pn') 
 	        {
 	            pnOld = 'pn=' + tmp[1];
 	            pnNew = 'pn=1';
 	        }
 	    }
    }
    
    if (ppValue != '')
        url = window.location.toString().replace(ddName+"="+ppValue,ddName+"=" + document.getElementById(ddName)[document.getElementById(ddName).selectedIndex].value);
    else
        if (window.location.toString().indexOf('?')>-1)
            url = window.location.toString() + "&"+ddName+"=" + document.getElementById(ddName)[document.getElementById(ddName).selectedIndex].value;
        else
            url = window.location.toString() + "?"+ddName+"=" + document.getElementById(ddName)[document.getElementById(ddName).selectedIndex].value;

    window.location.href = url.replace(pnOld, pnNew);
 }
 
 
 function WriteFlashObjectToClipVideo(videoSrc, isWide)
{
    if (videoSrc.indexOf('.flv')>0)
    {
        var h = isWide ? '200' : '265';
        var h2 = isWide ? '235' : '300';
        var mainFlashVars       = {};
        mainFlashVars.width	    = '365';
        mainFlashVars.height    = h;//'265';
        mainFlashVars.buffer    = '2';
        mainFlashVars.autoplay  = 'true';
        mainFlashVars.skin	    = '/flash/ECLShotPlayerSkin.swf';
        mainFlashVars.src	    = videoSrc;

        var mainParams              = {};
        mainParams.allowFullScreen  = 'true';
        mainParams.wmode            = 'window';
        mainParams.id               = 'mp3Player';
        mainParams.quality          = 'high';

        swfobject.embedSWF('/flash/ECLShotPlayer.swf', 'VideoPath', '365', h2, '8.0.0','/script/expressInstall.swf',mainFlashVars,mainParams );
    }     
    else
    {
        var divElem = document.getElementById('VideoPath');
        var newImage = document.createElement("img");
        newImage.src = '/i/nopreview_available.png';       
        divElem.appendChild(newImage);        
    }    
}

function DisableOrNotDeliveryAddress(currentProdType)
{
    var elements = document.getElementById('addressForm').getElementsByTagName("*");

     var isEnable = (currentProdType == 'download') ? true : false;
    
    for(var i=1; i < elements.length; i++)
    {
        elements.item(i).disabled = isEnable;
    }
}

Event.observe(window, 'load', function() {
	Event.observe(document, 'keyup', function(e){
		var code;
		if (!e) var e = window.event;
		if (e.keyCode) code = e.keyCode;
		else if (e.which) code = e.which;
		
	});
});
Event.addBehavior ( {
    '#lnkSelectAll:click' : function(e) {
        e.stop();
        if ( this.innerHTML == "Select All" )
        {
            this.innerHTML = "Deselect All";
            check = true;
        }else{
            this.innerHTML = "Select All";
            check = false;
        }
        
        $$('.ages').each( function(e) {e.checked = check });
       
    },
    '#lnkSelectAllLanguages:click' : function(e) {
        e.stop();

        if ( this.innerHTML == "Select All" )
        {
            this.innerHTML = "Deselect All";
            check = true;
        }else{
            this.innerHTML = "Select All";
            check = false;
        }
        
        $$('.languages').each( function(e) {e.checked = check });
       
    }
})