﻿var ws;
function createEnvelope()
{
	var txt1 = document.getElementById('ctl00_m_g_de6857ef_e9e4_4f8a_934a_0f8003fc8853_ff1_1_ctl00_ctl00_TextField').value;
	
   var soap = '<?xml version="1.0" encoding="utf-8"?>';
   soap += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
   soap += '<soap:Body>';
   soap += '<UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">';   
   soap += '<listName>NewsletterMembers</listName><updates><Batch>';
   soap += '<Method ID="1" Cmd="New"><Field Name="Title">'+txt1+'</Field></Method></Batch></updates>';
   soap += '</UpdateListItems></soap:Body></soap:Envelope>';    
	return soap;
}

function createXMLHttpRequest() 
    {          
        if (window.ActiveXObject)
        {
           try
           {
              ws = new ActiveXObject("Microsoft.XMLHTTP");
           } 
           catch (e)
           {
              ws = new ActiveXObject("Msxml2.XMLHTTP");
           }
         }
        else
              ws = new XMLHttpRequest();
                 
    }  
function CreateListItem()
	{
			
	var soap = createEnvelope();	
	createXMLHttpRequest();
	ws.onreadystatechange = stateChange;
	ws.open("POST", "http://neweducation.systemgroup.net/_vti_bin/lists.asmx", true);
	ws.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
	ws.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");
	ws.send(soap);			  	  

	}
	function stateChange()
	{
	try{    
      if (ws.readyState == 1)
      {                
        document.getElementById('divWait').style.display = '';
      }
      else
        if (ws.readyState == 4)
        {
        	document.getElementById('divWait').style.display = 'none';
            
            if (ws.status == 200)
            {
	            document.getElementById('ctl00_m_g_de6857ef_e9e4_4f8a_934a_0f8003fc8853_ff1_1_ctl00_ctl00_TextField').value = "";    
				document.getElementById('divOk').style.display = '';				
				document.getElementById('LblOK').style.display = '';                							
		     }
		    else
            { 
	         	document.getElementById('divFail').style.display = '';
            }
        }
        else
        {
        }
        }
     catch(e)
     {
     }
}

function setvalMC()
{
    if (gup('%40_x06a9__x062f__x0020__x06a9__x06') != "")
    {
		document.getElementById('ctl00_m_g_7a0084c7_2ce5_430e_93a9_002ecac17ed5_ff5_1_ctl00_ctl00_TextField').value = gup('%40_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('ctl00_m_g_7a0084c7_2ce5_430e_93a9_002ecac17ed5_ff4_1_ctl00_ctl00_TextField').value = unescapeProperly(gup('%40_x062f__x0648__x0631__x0647__x00'));
	}
	else
	{
    	document.getElementById('ctl00_m_g_7a0084c7_2ce5_430e_93a9_002ecac17ed5_ff5_1_ctl00_ctl00_TextField').value = gup('@_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('ctl00_m_g_7a0084c7_2ce5_430e_93a9_002ecac17ed5_ff4_1_ctl00_ctl00_TextField').value = unescapeProperly(gup('@_x062f__x0648__x0631__x0647__x00'));	
	}	
}

function setvalCustomer()
{
    if (gup('%40_x06a9__x062f__x0020__x06a9__x06') != "")
    {               
		document.getElementById('ctl00_m_g_7e5cbbef_6210_445e_9570_81bce10c83a7_ff6_1_ctl00_ctl00_TextField').value = gup('%40_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('ctl00_m_g_7e5cbbef_6210_445e_9570_81bce10c83a7_ff5_1_ctl00_ctl00_TextField').value = unescapeProperly(gup('%40_x0645__x0627__x0647_'));
		document.getElementById('ctl00_m_g_7e5cbbef_6210_445e_9570_81bce10c83a7_ff11_1_ctl00_ctl00_TextField').value = document.getElementById('ctl00_m_g_845ede8e_09e0_407f_83ef_9291abbdec35_ff1_1').value;
		document.getElementById('Text1').value = unescapeProperly(gup('%40_x0645__x0627__x0647_'));
		document.getElementById('Text2').value = gup('%40_x06a9__x062f__x0020__x06a9__x06');		
		document.getElementById('Text4').value = document.getElementById('ctl00_m_g_845ede8e_09e0_407f_83ef_9291abbdec35_ff1_1').value;

	}
	else
	{	
	   	document.getElementById('ctl00_m_g_7e5cbbef_6210_445e_9570_81bce10c83a7_ff6_1_ctl00_ctl00_TextField').value = gup('@_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('ctl00_m_g_7e5cbbef_6210_445e_9570_81bce10c83a7_ff5_1_ctl00_ctl00_TextField').value = unescapeProperly(gup('@_x0645__x0627__x0647_'));
		document.getElementById('ctl00_m_g_7e5cbbef_6210_445e_9570_81bce10c83a7_ff11_1_ctl00_ctl00_TextField').value = document.getElementById('ctl00_m_g_845ede8e_09e0_407f_83ef_9291abbdec35_ff1_1').value;
		document.getElementById('Text1').value = unescapeProperly(gup('@_x0645__x0627__x0647_'));
		document.getElementById('Text2').value = gup('@_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('Text4').value = document.getElementById('ctl00_m_g_845ede8e_09e0_407f_83ef_9291abbdec35_ff1_1').value;
		

	}
	  
	
}

function setvalCUE()
{
    if (gup('%40_x06a9__x062f__x0020__x06a9__x06') != "")
    {
		document.getElementById('ctl00_m_g_aa10af99_cd04_4d3d_8844_d52cf3fb5cf5_ff6_1_ctl00_ctl00_TextField').value = gup('%40_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('ctl00_m_g_aa10af99_cd04_4d3d_8844_d52cf3fb5cf5_ff5_1_ctl00_ctl00_TextField').value = unescapeProperly(gup('%40_x0645__x0627__x0647_'));
	}
	else
	{
    	document.getElementById('ctl00_m_g_aa10af99_cd04_4d3d_8844_d52cf3fb5cf5_ff6_1_ctl00_ctl00_TextField').value = gup('@_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('ctl00_m_g_aa10af99_cd04_4d3d_8844_d52cf3fb5cf5_ff5_1_ctl00_ctl00_TextField').value = unescapeProperly(gup('@_x0645__x0627__x0647_'));	
	}	
}

function setvalUC()
{
    if (gup('%40_x06a9__x062f__x0020__x06a9__x06') != "")
    {
		document.getElementById('ctl00_m_g_d5b38d3c_0a93_4265_bb76_0db2ebaf591b_ff6_1_ctl00_ctl00_TextField').value = gup('%40_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('ctl00_m_g_d5b38d3c_0a93_4265_bb76_0db2ebaf591b_ff5_1_ctl00_ctl00_TextField').value = unescapeProperly(gup('%40_x0645__x0627__x0647_'));
	}
	else
	{
    	document.getElementById('ctl00_m_g_d5b38d3c_0a93_4265_bb76_0db2ebaf591b_ff6_1_ctl00_ctl00_TextField').value = gup('@_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('ctl00_m_g_d5b38d3c_0a93_4265_bb76_0db2ebaf591b_ff5_1_ctl00_ctl00_TextField').value = unescapeProperly(gup('@_x0645__x0627__x0647_'));	
	}	
}
function setvalUCo()
{
     document.getElementById('ctl00_m_g_05a5d040_d1fa_4a4c_8f81_9eef4929b3a4_ff16_1_ctl00_ctl00_TextField').value = document.getElementById('ctl00_m_g_1b907e70_88a5_4109_be92_29d6bd98d90c_ff1_1').value;
     document.getElementById('Text2').value = document.getElementById('ctl00_m_g_1b907e70_88a5_4109_be92_29d6bd98d90c_ff1_1').value;
    if (gup('%40_x06a9__x062f__x0020__x06a9__x06') != "")
    {
		document.getElementById('ctl00_m_g_05a5d040_d1fa_4a4c_8f81_9eef4929b3a4_ff6_1_ctl00_ctl00_TextField').value = gup('%40_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('ctl00_m_g_05a5d040_d1fa_4a4c_8f81_9eef4929b3a4_ff5_1_ctl00_ctl00_TextField').value = unescapeProperly(gup('%40_x0645__x0627__x0647_'));
		document.getElementById('Text3').value =  gup('%40_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('Text1').value = unescapeProperly(gup('%40_x0645__x0627__x0647_'));

	}
	else
	{
    	document.getElementById('ctl00_m_g_05a5d040_d1fa_4a4c_8f81_9eef4929b3a4_ff6_1_ctl00_ctl00_TextField').value = gup('@_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('ctl00_m_g_05a5d040_d1fa_4a4c_8f81_9eef4929b3a4_ff5_1_ctl00_ctl00_TextField').value = unescapeProperly(gup('@_x0645__x0627__x0647_'));	
		document.getElementById('Text3').value =  gup('@_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('Text1').value =	unescapeProperly(gup('@_x0645__x0627__x0647_'));	
	}	
}

function setvalUE()
{
        document.getElementById('ctl00_m_g_1fe98d05_85a2_43a2_a0f0_98998003e519_ff16_1_ctl00_ctl00_TextField').value = document.getElementById('ctl00_m_g_cd1fb390_ca9e_43bc_b5e2_68aebc4400d1_ff1_1').value;
        document.getElementById('Text3').value = document.getElementById('ctl00_m_g_cd1fb390_ca9e_43bc_b5e2_68aebc4400d1_ff1_1').value;
	if (gup('%40_x06a9__x062f__x0020__x06a9__x06') != "")
	{
		document.getElementById('ctl00_m_g_1fe98d05_85a2_43a2_a0f0_98998003e519_ff6_1_ctl00_ctl00_TextField').value = gup('%40_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('ctl00_m_g_1fe98d05_85a2_43a2_a0f0_98998003e519_ff5_1_ctl00_ctl00_TextField').value = unescapeProperly(gup('%40_x0645__x0627__x0647_'));
		document.getElementById('Text1').value = unescapeProperly(gup('%40_x0645__x0627__x0647_'));
		document.getElementById('Text2').value = gup('%40_x06a9__x062f__x0020__x06a9__x06');
	}
	else
	{
		document.getElementById('ctl00_m_g_1fe98d05_85a2_43a2_a0f0_98998003e519_ff6_1_ctl00_ctl00_TextField').value = gup('@_x06a9__x062f__x0020__x06a9__x06');
		document.getElementById('ctl00_m_g_1fe98d05_85a2_43a2_a0f0_98998003e519_ff5_1_ctl00_ctl00_TextField').value = unescapeProperly(gup('@_x0645__x0627__x0647_'));
		document.getElementById('Text1').value = unescapeProperly(gup('@_x0645__x0627__x0647_'));
		document.getElementById('Text2').value = gup('@_x06a9__x062f__x0020__x06a9__x06');

	}

}	

function displaywp(show,hd1,hd2,hd3,hd4,hd5)
	{
        document.getElementById(show).style.display = '';	
		document.getElementById(hd1).style.display = 'none';
		document.getElementById(hd2).style.display = 'none';
		document.getElementById(hd3).style.display = 'none';
		document.getElementById(hd4).style.display = 'none';
		document.getElementById(hd5).style.display = 'none';	
	}

function gup(name)
	{  
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
	var regexS = "[\\?&]"+name+"=([^&#]*)";  
	var regex = new RegExp(regexS);  
	var results = regex.exec(window.location.href);  
	if(results == null)    
	return "";  
	else    
	return results[1];
	}
	
function setCookie(sName, sValue, oExpires, sPath, sDomain, bSecure) 
	{
		var sCookie = sName + "=" + encodeURIComponent(sValue);
		if (oExpires) {
		sCookie += "; expires=" + oExpires.toGMTString();
		}
		if (sPath) {
		sCookie += "; path=" + sPath;
		}
		if (sDomain) {
		sCookie += "; domain=" + sDomain;
		}
		if (bSecure) {
		sCookie += "; secure";
		}
		document.cookie = sCookie;
	}
	
function getCookie(sName) 
	{
		var sRE = "(?:; )?" + sName + "=([^;]*);?";
		var oRE = new RegExp(sRE);
		if (oRE.test(document.cookie)) {
		return decodeURIComponent(RegExp["$1"]);
		} else {
		return null;
		}
	}
	
function createListItem()
	{
			
	var soap = createEnvelope();	
	var ws = new ActiveXObject("Microsoft.XMLHTTP");
	ws.open("POST", "http://neweducation.systemgroup.net/_vti_bin/lists.asmx", false);
	ws.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
	ws.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");
	ws.send(soap);
	if (ws.Status == 200)
	      {                
				var xmlResponse = new ActiveXObject("MSXML2.DOMDocument.3.0");
	            xmlResponse.async = false;
		        xmlResponse = ws.ResponseXML ;
	
				var node = xmlResponse.lastChild.childNodes[0].nodeValue;
				alert ('ثبت نام با موفقيت انجام شد');			
		   }
		   else
		   alert('خطا در ثبت اطلاعات');      

	}

function RemoveNL(S)
	{
		var st = new String(S.replace(/systemgroup/gi,"systemgroup\\"));
		r = "";		
		if ( st.charAt(12) == '\f' || st.charAt(12) == '\b' || st.charAt(12) == '\n' || st.charAt(12) == '\t' || st.charAt(12) == '\r' || st.charAt(12) == '\v' || st.charAt(12) == '\O' )
		{
		  for (i=0; i < st.length; i++) 
		  {
    		 if (st.charAt(i) == '\n')
    		  {
    			r += st.replace(st.charAt(i),'N');
    	      }
    		  else if (st.charAt(i) == '\r')
  		      {
  			  	r += st.replace(st.charAt(i),'R');
      		  }
      		  else if (st.charAt(i) == '\t')
  		      {
  			  	r += st.replace(st.charAt(i),'T');
      		  }
      		  else if (st.charAt(i) == '\O')
  		      {
  			  	r += st.replace(st.charAt(i),'o');
      		  }
      		  else if (st.charAt(i) == '\b')
  		      {
  			  	r += st.replace(st.charAt(i),'B');
      		  }
      		  else if (st.charAt(i) == '\f')
  		      {
  			  	r += st.replace(st.charAt(i),'F');
      		  }
      		  else if (st.charAt(i) == '\v')
  		      {
  			  	r += st.replace(st.charAt(i),'V');
      		  }    		    			      		      		    			
		   }
  			return r;
  		}
  		else return st;
	}

