// JavaScript Document
function swapshow(div_id) {
if(document.getElementById(''+div_id+'').style.display == 'none') document.getElementById(''+div_id+'').style.display = 'block' ;
else document.getElementById(''+div_id+'').style.display = 'none';

}
function include(filename)
{
	var head = document.getElementsByTagName('head')[0];
	
	script = document.createElement('script');
	script.src = filename;
	script.type = 'text/javascript';
	
	head.appendChild(script)
}


		function submitLogin()
		{
			xajax.$('submitButtonLogin').disabled=true;
			xajax.$('submitButtonLogin').value="please wait...";
			xajax_Dlogin(xajax.getFormValues("login_form"));
			return false;
		}


function logout() {
	xajax_Dlogout();
	return false;
}
function BothFieldsIdenticalCaseSensitive(ID_1,ID_2) {
	var TextField_1 = document.getElementById(ID_1);
	var TextField_2 = document.getElementById(ID_2);
	var T1= TextField_1.value;
	var T2= TextField_2.value;
//var one = document.reg_form.password.value;
//var another = document.reg_form.confpass.value;
	if(T1 == ''){
	alert("Oops, must enter something.");
	return false;	
	}
	if(T1 == T2 ) { 
	//alert("it work?.");
	return true; }
	alert("Oops, both fields must be identical.");
	return false;
}

function checkFields2() {
	
	
	if (document.signup_form.signupName.value == ""
		|| document.signup_form.signupEmail.value == "") {
		
		alert("Please Fill in Name and Email before submitting!");
		return false;
	}
	

	if (document.signup_form.signupEmail.value.indexOf("@") == -1 || document.signup_form.signupEmail.value.indexOf(".") == -1) {
		alert("Your email address is not valid.");
		return false;
	}
	
	return true;
}


var adTimerId = 0;

function img_box(img) {

document.getElementById('img_box').innerHTML='<div style="text-align:center; margin-top:100px;">Loading...</div>';

var myImage = new Image();
myImage.name = img;
myImage.onload = getWidthAndHeight;
myImage.onerror = loadFailure;

myImage.src = img;

}


function getWidthAndHeight() {
	var holder = document.getElementById("photo_holder");
	
	var div_height = parseInt(holder.style.height);
	var div_width = parseInt(holder.style.width);

if(	this.width > this.height){
	var imageposition = "width";
	var percentage = (div_width / this.width);

}else{
	var imageposition = "height";
	var percentage = (div_height / this.height);

}
var image_width = Math.round(this.width * percentage);
var image_height = Math.round(this.height * percentage);
//alert(image_width+"w "+image_height+"h ");
var top_margin = (div_height - image_height) / 2;
var left_margin = (div_width - image_width) / 2;

var img_1 = document.getElementById('img_box');
	img_1.style.marginTop=top_margin+'px';
	img_1.style.marginLeft=left_margin+'px';
	img_1.style.width=image_width+"px";
	img_1.style.height=image_height+"px";

	holder.style.visibility="visible";

	var img_view = "<img src='"+this.name+"' width='100%' height='100%' />";
        
img_1.innerHTML=img_view;

	
	
    return true;
}
function loadFailure() {
    alert("'" + this.name + "' failed to load.");
    return true;
}

