		// coded by A.Suresh Kumar - 13-10-2007
		
		function wopen1()	// user click service aggrement link
		{
			
			window.open("Mobi33_ServiceSubscriptionAgreement.php","", "width=700,height=650,left=30,top=30, scrollbars=yes");
				
		}
		function wopen2()	// user click user guide link
		{
			
			window.open("http://www.mobi33.com/HelpDocs/QuickStart/QuickStart.html","","toolbars=0, Location=0, height=650, width=700,left=60,top=50,scrollbars=1,resizable=1");
			
		}
		function wopen3()	
		{			
			window.open("accessinfo.html","","toolbars=0, Location=0, height=450, width=500,left=60,top=50,scrollbars=1,resizable=1");				
		}
		function m_in(val1){
	
			document.getElementById(val1).style.color='#FF0068';
			
		}
		function m_out(val1){
	
			document.getElementById(val1).style.color='#201E1F';
			
		}
		function limitText(limitField, limitCount, limitNum) {
	
  			if (limitField.value.length > limitNum) {
				limitField.value = limitField.value.substring(0, limitNum);
			} else {
				limitCount.value = limitNum - limitField.value.length;
			}
		}
		
		function InstantDemoValidate(formN){
			
			if(document.forms[formN].keyword.value == ""){
				
					alert("Please Enter A Keyword");
					
					document.forms[formN].keyword.focus();
					
					return false;
			}else{
				
					var theText = document.forms[formN].keyword.value;
				
					var Temp = new Array();
					
					var TextSize = theText.length;
					
					if(TextSize < 2){
						
						alert('Your Instant Demo Keyword must contain a minimum of 2 characters');
		
						document.forms[formN].keyword.focus();
	
						return false;
					}
					
					for (i = 0; i < TextSize; i++) {
						
						Temp[i] = theText.charCodeAt(i);
						
                        if((Temp[i] < 48 && Temp[i] !=43 && Temp[i] !=45) || ( Temp[i] > 57 && Temp[i] < 65 && Temp[i] !=58 && Temp[i] !=61) || ( Temp[i] > 90 && Temp[i] < 97 ) || (Temp[i] > 122 ))
                        {
							alert('Your Instant Demo Keyword must be alpha numeric characters and [+-:=] symbols only');
		
							document.forms[formN].keyword.focus();
	
							return false;
							
							break;
						}
					}
			}
			
			if(document.forms[formN].ufile.value != ""){
				
					var ext = document.forms[formN].ufile.value;
					
					var len, get_ext = new Array();
					
					ext.replace("\b", "-");
					
					get_ext = ext.split(".");
					
					len = get_ext.length;
					
					ext = get_ext[len-1].toLowerCase();
			
					if(ext != 'jpg' && ext != 'gif') {
					
						alert('Please upload a jpg or a gif image!');
				
	    				document.forms[formN].ufile.focus();
	    							
						return false; 
					}
			}
			
			if(document.forms[formN].message.value == ""){
				
					alert("Please Enter An Ad Message");
					
					document.forms[formN].message.focus();
					
					return false;
			}else{
				
					var adtext = document.forms[formN].message.value;
					
					var sms_textmessage_length = parseInt(document.forms[formN].sms_textmessage_length.value);
					
					if(adtext.length > sms_textmessage_length)
					{
					
						alert("Your Ad Message limit is "+sms_textmessage_length+" chars only.");
	
						document.forms[formN].message.focus();
	
						return false;
					}
			}
			
			ajax_keyword_valid(theText,formN);	// check the keyword unique
			
			return false;
						
		}
		
		function ajax_keyword_valid(codename,form_N){	// fn will content to webserver in backend to perform code name unique validation
			
			var ajaxhttprequest = null;
				
			var url="eMobiAd/codename_ajax_validation.php";	// file name
		
			var post_str="cd="+codename;
			
			if(typeof ajaxhttprequest == 'object'){ ajaxhttprequest = null;}
			
			if (window.XMLHttpRequest){              //IE7 and mozilla
							
        		ajaxhttprequest = new XMLHttpRequest();
        	
			}else if(window.ActiveXObject){	// IE <=6
       
				ajaxhttprequest = new ActiveXObject("Microsoft.XMLHTTP");	// to avoid the cache problem in IE
				
			}else{
			
				ajaxhttprequest = null;	
			}
			
        	if (ajaxhttprequest != null){
        		
        		ajaxhttprequest.open("POST", url,true); // post method
           
            	// content type
            
            	ajaxhttprequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            
				ajaxhttprequest.setRequestHeader("Content-length", post_str.length);
			
				ajaxhttprequest.setRequestHeader("Connection", "close");
				
				if(navigator.appName == "Microsoft Internet Explorer"){	// IE
					
					ajaxhttprequest.onreadystatechange = function() {
        					        				        				       				
        				if (ajaxhttprequest.readyState == 4 && ajaxhttprequest.status == 200) {
        				
        					var response = ajaxhttprequest.responseText;
        						        					      					
        					if(response == 'invalid'){
        							
								alert('Your Instant Demo Keyword already exist, please enter another keyword!');
	
								document.forms[form_N].keyword.focus();

        					}else{
       									
								var rows=document.forms[form_N].getElementsByTagName('input');
	   		
								for ( var i = 0; i < rows.length; i++ ) {
	    			
	    							if(rows[i].type == 'submit' || rows[i].type == 'button'){
	    		
	    								rows[i].disabled=true;
	    			
		 							}
								}
	
								document.getElementById('loadingmsg').style.display='block';
																		
								document.forms[form_N].submit();
	        				}
        				}
					}
        			
				}else{	// Firefox,Safari
					
					ajaxhttprequest.onload = function() {
        				                			
        				if (ajaxhttprequest.readyState == 4 && ajaxhttprequest.status == 200) {
        					
        					var response = ajaxhttprequest.responseText;
        						        					      					
        					if(response == 'invalid'){
        							
								alert('Your Instant Demo Keyword already exist, please enter another keyword!');
	
								document.forms[form_N].keyword.focus();

        					}else{
       									
								var rows=document.forms[form_N].getElementsByTagName('input');
	   		
								for ( var i = 0; i < rows.length; i++ ) {
	    			
	    							if(rows[i].type == 'submit' || rows[i].type == 'button'){
	    		
	    								rows[i].disabled=true;
	    			
		 							}
								}
	
								document.getElementById('loadingmsg').style.display='block';
																		
								document.forms[form_N].submit();
        					}
        				}
        			
					}
				}
				
				ajaxhttprequest.send(post_str);	// send the parameter to web server	
        	}
			
		}
