/* ---------------------------- */
/* XMLHTTPRequest Enable */
/* ---------------------------- */
function createObjectf() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObjectf();


/* -------------------------- */
/* INSERT */
/* -------------------------- */
/* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
var nocache = 0;
function tellfriendmail() {
	//alert('sdsdsd');
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('myform1_errorloc').innerHTML = "processing..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var friends_email_id= encodeURI(document.getElementById('enter your friend\'s email').value);
var product_id= encodeURI(document.getElementById('productidn').value);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get','tellfriend.php?friends_email_id='+friends_email_id+'&prdid='+product_id+'&nocache = '+nocache);
http.onreadystatechange = insertReplyf;
http.send(null);
}


function insertReplyf() {
if(http.readyState == 4){ 
var response = http.responseText;
var postion_error_word=(response.search(/error/));
document.getElementById('myform1_errorloc').innerHTML =''+response;
 document.getElementById("posttell").style.display="none";
// else if login is ok show a message: "Site added+ site URL".
}
}
//for ask question
function askquestion() {
	//alert('sdsdsd');
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('askquestion_errorloc').innerHTML = "processing..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var question= document.getElementById('Please type your question here and click submit').value;
var vendorid= document.getElementById('vendorid').value;
var productid = document.getElementById('productid').value;
var userid = document.getElementById('userid').value;
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get','tellfriend.php?question='+question+'&vendorid='+vendorid+'&productid='+productid+'&userid='+userid+'&nocache = '+nocache);
http.onreadystatechange = insertReplyask;
http.send(null);
}


function insertReplyask() {
if(http.readyState == 4){ 
var response = http.responseText;
var postion_error_word=(response.search(/error/));
document.getElementById('askquestion_errorloc').innerHTML =''+response;
 document.getElementById("paskquet").style.display="none";
// else if login is ok show a message: "Site added+ site URL".
}
}
//for ask question
function subscribe() {
	//alert('sdsdsd');
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('myform_subscribe_errorloc').innerHTML = "processing..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var subscribemail= encodeURI(document.getElementById('enter your email').value);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get','http://www.ekriti.com/utilities/php/tellfriend.php?subscribemail='+subscribemail+'&nocache = '+nocache);
http.onreadystatechange = insertReplysubscribe;
http.send(null);
}


function insertReplysubscribe() {
if(http.readyState == 4){ 
var response = http.responseText;
var postion_error_word=(response.search(/error/));
document.getElementById('myform_subscribe_errorloc').innerHTML =''+response;
// else if login is ok show a message: "Site added+ site URL".
}
}

//for select state
function selectstate() {
		//alert('sdsdsd');
	// Optional: Show a waiting message in the layer with ID login_response
	// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
	//document.getElementById('statelist').innerHTML = "processing......"
	var country= encodeURI(document.getElementById('Country').value);
	var stateValue= encodeURI(document.getElementById('stateSelValue').value);
	// Set te random number to add to URL request
	nocache = Math.random();
	// Pass the login variables like URL variable
	http.open('get','http://www.ekriti.com/utilities/php/selstate.php?country='+country+'&stateVal='+stateValue+'&nocache = '+nocache);
	//http.open('get','http://www.ekriti.com/testserver/utilities/php/selstate.php?country='+country+'&stateVal='+stateValue+'&nocache = '+nocache);
	http.onreadystatechange = insertReplyselectstate;
	http.send(null);
}


function insertReplyselectstate() {
	if(http.readyState == 4){ 
		var response = http.responseText;
		var postion_error_word=(response.search(/error/));
		document.getElementById('statelist').innerHTML =''+response;
		// else if login is ok show a message: "Site added+ site URL".
	}
}

