﻿var Browser = new Object();
		
		Browser.isIE 	  = window.ActiveXObject ? true : false;
		Browser.isIE6 = ( Browser.isIE&& /msie 6\.0/i.test(navigator.userAgent) );
		Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
		Browser.isOpera   = (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
		Browser.isSafari = (navigator.userAgent.toLowerCase().indexOf("safari")!=-1);
		

var OS = new Object();
	OS.isLinux = (navigator.platform.toLowerCase().indexOf("linux")!=-1);
	OS.isMac = (navigator.platform.toLowerCase().indexOf("mac")!=-1);
	OS.isWindows = (navigator.platform.toLowerCase().indexOf("win")!=-1);


function createWindow(config){
	var windContainer = document.getElementById("windowsContainer");
	
	var windowStr =
	'<a class="'+config.id+'_shine" href="javascript:void(0)"  onmouseover="playSound(\''+config.id+'\')" onmouseout="stopSound(\''+config.id+'\')"><div  id="'+config.id+'" class="'+config.id+'"></div></a>'+
	''+
 	
    '<div  class="window popup  '+config.id+'_window" id="'+config.id+'_container">'+
        '<div class="window_header popup_draghandle '+config.id+'_header">'+
			'<div style="float:left" class="window_title  '+config.id+'_title" alt="'+config.title+'" title="'+config.title+'">'+config.title+'</div>'+
			'<img src="images/close.png" class="popup_closebox window_closebox '+config.id+'_close"/>'+
		
        '</div>'+
        '<div class="window_content '+config.id+'_content"  id="'+config.id+'_content">'+
        	
        '</div>'+
    '</div>';
	
	windowStr += addBgSound(config.id, config.sound);
	

	var containerDiv = document.createElement("div");
	containerDiv.innerHTML = windowStr;
	windContainer.appendChild(containerDiv);
	
	
	if(config.fillcontent){
		eval(config.fillcontent+"('"+config.id+"_content')");	
		
	}
}


/*radio link*/
createWindow(radio_link_config);
new Popup(radio_link_config.id + '_container',radio_link_config.id, { "position": radio_link_config.position});

/*sms box*/
createWindow(smsbox_link_config);
new Popup(smsbox_link_config.id + '_container',smsbox_link_config.id, { "position":smsbox_link_config.position} );

/*sms box 2*/
createWindow(smsbox2_link_config);
new Popup(smsbox2_link_config.id + '_container',smsbox2_link_config.id, { "position":smsbox2_link_config.position} );

/*news_link*/
createWindow(news_link_config);
new Popup(news_link_config.id + '_container',news_link_config.id,{ "position": news_link_config.position});

/*contactUs_link*/
createWindow(contactUs_link_config);
new Popup(contactUs_link_config.id + '_container',contactUs_link_config.id, { "position":contactUs_link_config.position});


/*contactUs_link*/
createWindow(europeanPerspective_link_config);
new Popup(europeanPerspective_link_config.id + '_container',europeanPerspective_link_config.id, { "position":europeanPerspective_link_config.position});



function ValidateForm (name, mail, subject, message) {

	if (name == ""){
		alert("Name field can't be empty.");
		return (false);
	}
	
	if (mail == ""){
		alert("Mail field can't be empty.");
		return (false);
	}
	
	if (message == ""){
		alert("Message field can't be empty.");
		return (false);
	}
	
	return true;
}

function sendContactUsMail(){
		document.getElementById("cu_send_mail_status").innerHTML = "Ուղարկվում է ...";
		var name = document.getElementById("cu_sender_name").value;
		var mail = document.getElementById("cu_sender_mail").value;
		var subject = document.getElementById("cu_sender_subject").value;
		var message = document.getElementById("cu_sender_message").value;
		
		if(ValidateForm(name, mail, subject, message)){
			var data = "sender_name="+name+"&sender_mail="+mail+"&sender_subject="+subject+"&sender_message="+message+"&type=contactus";
			Request.sendPOST("sendmail.php",  data, resp_sendContactUsMail);
		}

}

function resp_sendContactUsMail(response){
	if(!response.responseText) return;
	var resp = response.responseText; 
	if(resp && resp == "sent"){
		document.getElementById("cu_send_mail_status").innerHTML = "Շհնորհակալություն, ձեր նամակը ուղարկված է:";
		
		document.getElementById("cu_sender_name").value = "";
		document.getElementById("cu_sender_mail").value = "";
		document.getElementById("cu_sender_subject").value = "";
		document.getElementById("cu_sender_message").value = "";
		
	}else{
		document.getElementById("cu_send_mail_status").innerHTML = "Ներեցեք, նամակը չուղարկվեց:";
	}
	setTimeout("clearErrorMessage('cu_send_mail_status')",5*1000);
}

function sendPatverMail(){
		document.getElementById("p_send_mail_status").innerHTML = "Ուղարկվում է ...";
		var name = document.getElementById("p_sender_name").value;
		var mail = document.getElementById("p_sender_mail").value;
		var subject = "Patverov Erajshtutiun";
		var message = document.getElementById("p_sender_message").value;
		
		if(ValidateForm(name, mail, subject, message)){
			var data = "sender_name="+name+"&sender_mail="+mail+"&sender_subject="+subject+"&sender_message="+message+"&type=patver";
			Request.sendPOST("sendmail.php",  data, resp_sendPatverMail);
		}

}

function resp_sendPatverMail(response){
	if(!response.responseText) return;
	var resp = response.responseText; 
	if(resp && resp == "sent"){
		document.getElementById("p_send_mail_status").innerHTML = "Շհնորհակալություն, ձեր նամակը ուղարկված է:";
		
		document.getElementById("p_sender_name").value = "";
		document.getElementById("p_sender_mail").value = "";
		document.getElementById("p_sender_subject").value = "";
		document.getElementById("p_sender_message").value = "";
		
	}else{
		document.getElementById("p_send_mail_status").innerHTML = "Ներեցեք, նամակը չուղարկվեց:";
		
	}
	setTimeout("clearErrorMessage('p_send_mail_status')",5*1000);
}

function clearErrorMessage(contId){
	document.getElementById(contId).innerHTML = "&nbsp;";
}


function addBgSound(idd, sound){
	var str = '';
	
	str += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="0" height="0" id="'+idd+'_bgsound" >'+
  '<param name=movie value="niftyplayer.swf?file='+sound+'&as=0">'+
  '<param name=quality value=high>'+
  '<param name=bgcolor value=#FFFFFF>'+
  '<embed src="niftyplayer.swf?file='+sound+'&as=0" quality=high bgcolor=#FFFFFF width="0" height="0" name="'+idd+'_bgsound"  type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">'+
  '</embed>'+
'</object>';
	
	
	return str;
}

function playSound(idd){
	//try{
		niftyplayer(idd+"_bgsound").play();
	//}catch(ex){}
}

function stopSound(idd){
	//try{
		niftyplayer(idd+"_bgsound").stop();
	//}catch(ex){}
	
}