// JavaScript Document

function insert_smartbut(){
	switch(wep.locale){
		case 'ro_RO' : imgnr = '21901'; break;
		case 'cs_CZ' : imgnr = '21902'; break;
		case 'hu_HU' : imgnr = '21903'; break;
		default : imgnr = '';
		};
  $('#smartimg').html('&nbsp;<img src="http://rs.instantservice.com/resources/smartbutton/6058/'+imgnr+'/available.gif?' + 
    Math.floor(Math.random()*10001) + '" style="width:0;height:0;visibility:hidden;position:absolute;"' + ' onLoad="agents_available()" onError="agents_not_available()">');
  }
	
function agents_available(){    
	var theChatURL ='';
	switch(wep.locale){
		case 'ro_RO' : theChatURL = "/support/ro/contacts/chat"; break;
		case 'cs_CZ' : theChatURL = "/support/cs/contacts/chat"; break;
		case 'hu_HU' : theChatURL = "/support/hu/contacts/chat"; break;
		default : theChatURL = '';
		};
	
	$('#smartbutton').html('<img src="https://admin.instantservice.com/brands/instantservice/images/clickhere.gif" onclick="javascript:window.open(\''+theChatURL+'\',\'_blank\',\'menubar=no, status=no, width=600,height=600\'); return false;" />');
	return true; 
} 	

  // IF AGENTS ARE NOT AVAILABLE:
function agents_not_available(){
	
	var theSentence ='';
	switch(wep.locale){
		case 'ro_RO' : theSentence = "Nici un agent nu este disponibil &#238;n acest moment.<br/>Va rugam sa ne trimiteti <a href=\"email\">ane-mail</a>.<br/>"; break;
		case 'hu_HU' : theSentence = "Jelenleg minden oper&#225;torunk foglalt.<br/>K&#233;rj&#252;k, k&#252;ldj&#246;n <a href=\"email\">emailt.</a><br/>"; break;
		case 'cs_CZ' : theSentence = "Omlouv&#225;me se, ale &#382;&#225;dn&#237; pracovn&#237;ci nejsou moment&#225;lne k dispozici.<br/>Pros&#237;m, za&#353;lete n&#225;m <a href=\"email\">e-mail.</a><br/>"; break;
		default : theSentence = '';
		};	
   $('#smartbutton').html(theSentence);
   return true;
  }

/* FOR VAIO */
function openChat(OS, WS, VPPS)
{
    //if ($('#chatfrm').validationEngine('validate')==true) {
    //    $("#sendChat").attr('disabled', 'disabled');
    //    var FullSerial = $('#ChatSerialNumber').val();
    //    var ProductCode = FullSerial.substr(0, 8);
    //    var SerialNumber = FullSerial.substr(9, 7);

        var ProductCode = $('#pc').val();
        var SerialNumber = $('#sn').val();	
        var Model = $('#mn').val();
       // var Language = $('#ChatLanguage').val();
        //var Country = $('#ChatCountry').val();
        var Name = $('#ChatFirstName').val();
        var LastName = $('#ChatLastName').val();
        var EmailAddress = $('#ChatEmailAddress').val();
        var url = 'https://sony.whoson.com/chat/chatstart.htm?domain=vaio.chat.english&x-ProductCode='+ProductCode+'&x-SerialNumber='+SerialNumber+'&x-Model='+Model+'&x-Language=en&x-Country=GB&Name='+Name+'&x-LastName='+LastName+'&x-EmailAddress='+EmailAddress+'&x-OS='+OS+'&x-WS='+WS+'&x-VPPS='+VPPS;
        window.open(url,"","resizable=no,toolbar=no,scrollbars=no,menubar=no,status=no,directories=no,");
   // }
}
function overrideLoad()
{
	if (sWOImage.width !== 1 && (wep.locale=='en_GB' || wep.locale=='en_IE'))
	{
		$("#en_chat").show();
		
	}
	else
	{
		$("#en_chat").hide();
		$('.contact').removeClass('triple').addClass('double');
		$('div.tribox').removeClass('tribox').addClass('bibox');
	}
}