function popupImage(theImage) {
     //var myWindow=window.open('viewer.php?image=' + theImage,'windowRef','width=500','height=500','resizable=true');
     //if (!myWindow.opener) myWindow.opener = self;
     popUp("viewer.php?image="+theImage);
}

function redirect(direction){
     window.location=direction;
}


function popupOpinion(){
     day = new Date();
     id = day.getTime();
     eval("page"+id+" = window.open('opinion.php' , '"+ id +"', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=728,height=190,left=200,top=150');");
}

function popupRefer(){
     day = new Date();
     id = day.getTime();
     eval("page"+id+" = window.open('refer.php' , '"+ id +"', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=728,height=190,left=200,top=150');");
}

function popUp(URL) {
	day = new Date();
	id = day.getTime() + "asd";
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=680,height=550');");
}

function popUp(URL, width, height) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,left=400,top=50,location=0,statusbar=0,menubar=0,resizable=1,width="+width+",height="+height+"');");
}

function popUp2(URL, width, height) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,left=300,top=0,location=0,statusbar=0,menubar=0,resizable=1,width="+width+",height="+height+"');");
}

function getElement(id) {
     return document.getElementById ? document.getElementById(id) :
     document.all ? document.all(id) : null;
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}

}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function addBookmark(title,url) {
     if (window.sidebar) {
          window.sidebar.addPanel(title, url,"");
     } else if( document.all ) {
          window.external.AddFavorite( url, title);
     } else if( window.opera && window.print ) {
          return true;
     }
}



function validateEmail(entered) {
     apos=entered.indexOf("@");
     dotpos=entered.lastIndexOf(".");
     lastpos=entered.length-1;
     if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) {
          return false;
     } else {
          return true;
     }
}

function validateNumber(x) {
     var anum=/(^\d+$)|(^\d+\.\d+$)/;
     if (anum.test(x)){
          return true;
     } else {
          return false;
     }
}

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s) {   
     var i;
     for (i = 0; i < s.length; i++) {
          // Check that current character is number.
          var c = s.charAt(i);
          if (((c < "0") || (c > "9"))) return false; 
     }
     // All characters are numbers.
     return true;
}

function stripCharsInBag(s, bag) {   
     var i;
     var returnString = "";
     // Search through string's characters one by one.
     // If character is not in bag, append to returnString.
     for (i = 0; i < s.length; i++) {
          // Check that current character isn't whitespace.
          var c = s.charAt(i);
          if (bag.indexOf(c) == -1) returnString += c;
     }
     return returnString;
}

function checkInternationalPhone(strPhone){
     s=stripCharsInBag(strPhone,validWorldPhoneChars);
     return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

