/* ========================================================================== */
/*  для взаимодействия с порталом минсвязи 10.02.2004 */
/* ========================================================================== */

function CheckURL(){
	try {
		if ( (window.parent.document.URL != document.URL) &&
			(window.parent.document.URL != "http://www.minsvyaz.ru/post_index.html") )
		{
			window.parent.location.href = document.URL;
		}
	} catch (er) {
		window.parent.location.href = document.URL;
	}
}


/* ========================================================================== */
/*  валидаторы */
/* ========================================================================== */

function validateAndSubmit()
{
	with (document.F1)
	{
	
	if (regLogin.value == "")
	{
	    alert('Please, enter Login name!');
	    regLogin.focus();
	    return false;
	}
	
	if (regPassword.value == "")
	{
	    alert('Please, enter Password!');
	    regPassword.focus();
	    return false;
	}
	
	return true;
	
	}
}


function cSubmit()
{
	with (document.F1){
		if (regLogin.value == "")
		{
			alert('Please, enter Login name!');
			regLogin.focus();
			return false;
		}
		else
		{
			if (regPassword.value == "")
			{
				alert('Please, enter Password!');
				regPassword.focus();
				return false;
			}
			submit();
		}
	}
}


function show(num,bln) {
	var link="/resp_engine.aspx?Path=RU/Home/aboutrussianpost/russianpoststructure/fps"+"&XMLPARAM_num="+num;
	//num.href=link;
	if (bln==1)
	{ 
		nw=window.open(link,"","menubar=no,scrollbars=0,resizable=no,width=450, height=280");
		// num.href="javascript:";
	} 
}


function openInNewWindow(wLink, wHeight, wWidth, wResize)
{
	window.open(wLink,"_blank","height="+wHeight+",width="+wWidth+",scrollbars=no, resizable="+wResize);
}

function sendMail()
{
	with (document.F1)
	{
		WHEREONOK.value = "COMPANY/EN/Home/Press/Accreditation/SubmitOk";
		PATHFROM.value = "COMPANY/EN/Home/Press/Accreditation/SubmitFailed";
		submit();
	}
}



/* ========================================================================== */
/* поиск по порталу */
/* ========================================================================== */

function sendSearch2()
{
	var strSearch = document.F1.searchAdd.value;
	var strLink = "/resp_engine.aspx?Path=PORTAL/EN/Home/Search" 
		+ "&unitid=8"
		+ "&keyword=" + strSearch;
	//alert(strLink);
	window.location = strLink;
	return false;
}
	
function sendSearch2OnEnter(evt)
{
	if (null == evt) { evt = window.event; }
	var code = evt.keyCode;
	//alert(code);
	if (code == 13) {
		sendSearch2();
		return false;
	}
	return false;
} 	


/* ========================================================================== */
/* поиск по порталу (старый)*/
/* ========================================================================== */

function sendSearch()
{
	var strSearch = document.F1.TEXTSEARCH.value;
	document.F1.action = "/resp_engine.aspx?Path=" + document.F1.PATHPAGE.value 
		+ "&SEARCHSTR=" + strSearch 
		+ "&PATHWEB=" + document.F1.PATHWEB.value 
		+ "&PATHPAGE=" + document.F1.PATHPAGE.value;
	document.F1.submit();
}

function changeSearchText()
{
	var strSearch = document.F1.TEXTSEARCH.value;
	document.F1.action = "/resp_engine.aspx?Path=" + document.F1.PATHPAGE.value 
		+ "&SEARCHSTR=" + strSearch 
		+ "&PATHWEB=" + document.F1.PATHWEB.value 
		+ "&PATHPAGE=" + document.F1.PATHPAGE.value;
}


/* ========================================================================== */
/* версия для печати */
/* ========================================================================== */


function SetPrintableOld() {
   with (document.F1){
   var PT,PB,link
    //PRINTTITLE.value=PrintTitleDiv.innerHTML;
    //PRINTBODY.value=PrintBodyDiv.innerHTML;
    link="/resp_engine.aspx?Path=PORTAL/EN/Home/print";
  //   action=link;
    window.open(link,"","menubar=yes,scrollbars=1,resizable=yes,width=750, height=500");

    }
}

function SetPrintable() {
	var strLink;
	var strSeparator = "";
	strLink = window.location.href;
	strSeparator = (strLink.indexOf("?") != -1) ? "&" : "?";
	var arrayStr = strLink.split("#");
	strLink = (arrayStr[0] != null) ? arrayStr[0] : "";
	strLink += strSeparator + "print=1";
	window.open(strLink, "", "menubar=yes, scrollbars=1, resizable=yes, width=750, height=500");
}

function GetPrintable() {
   with (document.F1){
   //alert(window.opener.parent.F1.PrintBodyDiv.innerHTML);

    if (!(window.opener.parent.document.all.item("PRINTTITLE")==null)) {
        PrintTitleDiv.innerHTML=window.opener.parent.document.all.item("PRINTTITLE").innerHTML;
      }

    if (!(window.opener.parent.document.all.item("PRINTBODY")==null)) {
        PrintBodyDiv.innerHTML=window.opener.parent.document.all.item("PRINTBODY").innerHTML;
      }
    }
}

/* ========================================================================== */
/* открытки */
/* ========================================================================== */


function EditPostCard(ID){
	with (document.F1){
		window.open ('postcards/sendpostcard_new.asp?POSTCARD='+ID,'_blank','width=1500,height=1000,resizable=yes,scrollbars=yes');
	}
}


/* ========================================================================== */
/* Подписка на новости                                                        */
/* ========================================================================== */

function isEmail2(who)
 {
	var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
	return(email.test(who));
}

function cEdit()
{
	with (document.F1)
   {         
var str =password.value;
var strMsg='';	

if (isEmail2(email.value) && (password.value)!='')
	  {
		var str='';		
		str ='/sub.aspx?LangID=2&OP=2&password='+ password.value + '&Email='+ email.value; 
		//alert(str);
		window.open(str,"_",'width=750, height=410, resizable=yes, scrollbars=yes');
	   }
		else
		{           if( (password.value) =='') 
			{
			 strMsg ='Please, enter password, password shouldn\'t have only spaces.\n';
			 password.focus();
			}
			//alert(email.value);
			if(!isEmail2(email.value))
 			{
			strMsg = strMsg + 'Please, enter correct E-Mail, \nExample: name@domain.(x), x - domen zone \n shouldn\'t have digits.';
			 email.focus();
			}
			alert(strMsg);
		}
	}
}


//-------------------------------------------------------------------------------------------------------------

function cSubMain()
{
with (document.F1)
	{
		if (isEmail2(email.value))
		{
		     var str='';		
		    str ='/sub.aspx?LangID=2&email='+ email.value + '&OP=-1'; 
	                       window.open(str,'_','width=760, height=390, resizable=1, scrollbars=1');
			OP.value='2';
			//target='_';
		}
		else
		{
                                           str ='/sub.aspx?LangID=2'; 
 	                       window.open(str,'_','width=760, height=390, resizable=1, scrollbars=1');
			OP.value='2';
			//target='_';
		}
	}
}


//-------------------------------------------------------------------------------------------------------------
function cResend()
{
with (document.F1)
	{
		if (isEmail2(email.value))
		{
		var str='';		
		str ='/resp_engine.aspx?Action=SS_Resend&OP=2&LangId=2&password='+ password.value + '&email='+ email.value; 

	                window.open(str,'_','width=740, height=380, resizable=1, scrollbars=1');
			OP.value='2';
			//target='_';
		}
		else
		{
			alert('Enter E-Mail');
			email.focus();
		}
	}
}

//-------------------------------------------------------------------------------------------------------------
function cAdd()
{
	with (document.F1)
                      {

if (email.value!='')
		{
			OP.value='1';
 var link="sub.aspx?",strsend='';
                      for (var i=0;i<item.length;i++)
                                         {
			if (item[i].checked==true) 
                                                              {
                                                                strsend = strsend + 'item='+item[i].value+ '&';
                                                                }

                                                            
                                           }
if (formattype[0].checked ==true)
 { strsend = strsend  + 'formattype=1';}

if (formattype[1].checked ==true)
 { strsend = strsend  + 'formattype=0';}

if (codetype[0].checked ==true)
 { strsend = strsend  + '&codetype=1';}

if (codetype[1].checked ==true)
 { strsend = strsend  + '&codetype=0';}

// '&codetype=' +codetype.value;

strsend = strsend  + '&email=' + email.value +'&OP=1' ; 
          window.open(link+strsend,"","menubar=no,scrollbars=1,resizable=1,width=840, height=200");
			
//submit();
		}
		else
		{
			alert('Enter E-Mail');
			email.focus();
		}		
	}
}
//-------------------------------------------------------------------------------------------------------------
function cClearForm()
{
	with (document.F1)
                      {
                                              
                               for (var i=0;i<item.length;i++)
                                         {
			item[i].checked=false;
                                           }
	}
}
var bl=0;
//-------------------------------------------------------------------------------------------------------------
function cEmail()
{
	if (bl==0)
	{
		F1.email.value='';
		bl=1;
	}
}
//-------------------------------------------------------------------------------------------------------------
function MakeSubscribe(num) 
{
      with (document.F1)
       {  
           var link="/resp_engine.aspx?Path=RU/Home/Services/rpprojects/cyberpost/pkd/pkd&NEWSID="+num;
           window.open(link,"","menubar=no,scrollbars=1,resizable=no,width=750, height=500");

       }
}

