// JavaScript Document
function getXMLHttp() {
	var http;
	try{
		http = new XMLHttpRequest();	
	} catch(e) {
		try {
			http = new ActiveXObject('Microsoft.XMLHTTP');	
		} catch(e) {
			alert("Your Browser Does not Support Ajax");
			return;
		}
	}
	return http;
}

var xmlHttp = getXMLHttp();

function discription(image) {
	if(image != '') {
		url = "aboutimage.php?sid=" + Math.random();
		url += "&imageid=" + image;
		//location.href = url;
		//showwindow(url);
		xmlHttp.onreadystatechange = alertdescription;
		xmlHttp.open("GET", url, "true");
		xmlHttp.send(null);
	}
}

function alertdescription() {
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		var response = xmlHttp.responseText;
		alert(response);
		return;
	}
}

function wedo() {
	alert("We Will develop websites");
	return;
}  

function showwindow(url) {
    try {
		var leftVal = (800 - screen.width) / 2;
		var topVal = (500 - screen.height) / 2;
        var windowfeatures = "toolbar=0,status=0,menubar=0,fullscreen=no,width=500,height=100,resizable=0,top=350,left=350,scrollbars=0,modal=yes";
        var newwindow = null;
        if(window.showModalDialog) {
            var dialogFeatures = "dialogWidth: 500px; dialogHeight: 100px;";
            window.showModalDialog(url,"kriyamedia",dialogFeatures);
        } else {
            newwindow=window.open(url,"kriyamedia",windowfeatures);
        }

        if(newwindow) {
            newwindow.focus();
        }
    } catch(e) {
    }
}

function validEmail(email){
	var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	str = email;
	if(str.match(emailRegEx)){
		return true;
	}else{
		return false;
	}
}	

function subscription() {
	xmlHttp = getXMLHttp();
	var subscribe = document.getElementById('sEmail').value;
	if(subscribe != '') {
		if(!validEmail(subscribe)) {
			alert("Enter a Valid Email");
			return;
		} else {
			url = "aboutimage.php?sid=" + Math.random();
			url += "&usub=" + subscribe;
			xmlHttp.onreadystatechange = alertsubscription;
			xmlHttp.open("GET", url, "true");
                        echo "Hello";
			xmlHttp.send(null);
                        echo "Hello after";
		}
	} else {
		alert("Enter Your Email-id for Subscription");
		return;
	}
}

function alertsubscription() {
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		var response = xmlHttp.responseText;
		if(response) {
			alert("Thank You for Your Subscription.");
			document.getElementById('sEmail').value = '';
			return;	
		} else {
			alert(response);
			return;
		}
	}	
}
