function image_open(image_loc)
{
  HTML = "<html><title>Single Slots</title> <style> body{margin:0px 0px 0px 0px}</style><body><img src='" + image_loc + "' border=0 name=load_image onLoad='window.resizeTo(document.load_image.width+10, document.load_image.height+30)'></body></html>";
  popupImage = window.open("", "_blank", "toolbar=no,scrollbars=no,height=20,width=20, top=20, left=20");
  popupImage.document.open();
  popupImage.document.write(HTML);
  popupImage.document.close();
}

function isEmail(address) 
{
	if (address != '' && address.search) 
	{
		if (address.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true;
		else return false;
	}
	var domain = address.substring(address.indexOf('@') + 1);
	if (domain.indexOf('.') == -1) return false;
	if (domain.indexOf('.') == 0 || domain.indexOf('.') == domain.length - 1) return false;
	return true;
}

function StringTrim(TRIM_VALUE){
  	if(TRIM_VALUE.length < 1){
     		return"";
       	}
       	TRIM_VALUE = RTrim(TRIM_VALUE);
       	TRIM_VALUE = LTrim(TRIM_VALUE);

        if(TRIM_VALUE==""){
         	return "";
           }
     	else{
		return TRIM_VALUE;
               }
           }
function RTrim(VALUE){
          var w_space = String.fromCharCode(32);
          var w_line  = String.fromCharCode(10);
	  var v_length = VALUE.length;
          var strTemp = "";
         if(v_length < 0){
          return "";
          }
          	var iTemp = v_length -1;
      	while(iTemp > -1){
 	if(VALUE.charAt(iTemp) == w_space || VALUE.charAt(iTemp) == w_line ){}
	else{
	strTemp = VALUE.substring(0,iTemp +1);
                      break;
                            		}
                            		iTemp = iTemp-1;
                            	}
								
                            	return strTemp;
                        }


                            function LTrim(VALUE){
                            	var w_space = String.fromCharCode(32);
								var w_line  = String.fromCharCode(10);
								var v_length = VALUE.length;
								var strTemp = "";
								var iTemp = 0;

                                	if(v_length < 1 ){
                                		return "";
                                	}
	while(iTemp < v_length){
	if(VALUE.charAt(iTemp) != w_space && VALUE.charAt(iTemp) != '\n') {
    strTemp = VALUE.substring(iTemp,v_length);
    break;}
	else{}
iTemp = iTemp + 1;
}
return strTemp;
}

function numeric(strng)
{	
	     var numeric=/[^0-9]/;
	      if (strng.match(numeric))
		{
			return false;
		}
		else 
		{
			return true;
		}
}

function IsValidEmail(strValue){
	nNoOfArguments = IsValidEMail.arguments.length;
	//if no parameter is supplied
	if(nNoOfArguments < 1)
	{
		return false;
	}	

	var testresults
	var str=strValue
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
		testresults=true
	else
		testresults=false

	return (testresults)
}

function checkEmailAddress(field) { 
var goodEmail = field.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi); 

if (goodEmail) { 

    return true;
} else { 
                return false; 
    } 
} 

function IsValidId(email) 
{
	
	var parsed = true;
	var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@._";
	//var email = prompt("What is your email address?", "nobody@nowhere.com");
	
	for (var i=0; i < email.length; i++) {
		var letter = email.charAt(i).toLowerCase();
		if (validchars.indexOf(letter) != -1)
			continue;
		else
			return false;
	}	
	return true;
}


function illegalchar(strng)
{
	var error;
	var illegalChars= /[\'\\\"]/;
	if (strng.match(illegalChars))
	{
		return false;
	}
		
	else
		return true;
		
}

function illegal(strng)
{
	var error;
	var illegalChars= /[\'\\\"]/;
	var illegalChars2= /[\(\)\<\>\[\]\{\}\'\;\:\?\&\*\`\|\/]/;
	var illegalChars4= /[\!\@\#\$\%\^\&\*\+\=\_]/;
	if (strng.match(illegalChars))
	{
		return true;
	}
	else if(strng.match(illegalChars2))
	{
		return true;
	}
	else
		return false;
}


function validateURL(url)
{
	lengthValue = url.length;
	if(lengthValue != 0)
	{
		/*var j = new RegExp();
		j.compile("^[A-Za-z]+://[A-Za-z0-9-]+\.[A-Za-z0-9]+"); 
		lengthValue = Trim(document.getElementById('txtWeb').value);
		if (!j.test(lengthValue))
		{ 
		alert(Please enter valid URL.");
		return false;
		}*/
		var filter=/^[A-Za-z]+:\/\/[A-Za-z0-9-]+\.[A-Za-z0-9]+/; 

		if (filter.test(url))
			testresults=true;
		else
			testresults=false
		return (testresults);
	}
}
function hideCombo()
{
	document.random.height=430;
	for(f=0;f<document.forms.length;f++)
		{
			for(el=0;el<document.forms[f].elements.length;el++)
			{
				if(document.forms[f].elements[el].type=="select-one")
					document.forms[f].elements[el].style.visibility="hidden";

			}
		}
}
function displayCombo()
{
	document.random.height=170;
		for(f=0;f<document.forms.length;f++)
		{
			for(el=0;el<document.forms[f].elements.length;el++)
			{
				if(document.forms[f].elements[el].type=="select-one")
					document.forms[f].elements[el].style.visibility="visible";

			}
		}
}

function isValidFileUploaded(filename) {
	 //making sure the user only uploads jpeg, jpg, gif files.
	var testStr = '.swf.SWF';
	var txt = filename;
	if (testStr.indexOf(txt.substring(txt.lastIndexOf('.'))) == -1) {
	  return false;
	}
	  return true;
}
function isValidImageFileUploaded(filename) {
	 //making sure the user only uploads jpeg, jpg, gif files.
	var testStr = '.jpg.JPG.gif.GIF.jpeg.JPEG.png.PNG';
	var txt = filename;
	if (testStr.indexOf(txt.substring(txt.lastIndexOf('.'))) == -1) {
	  return false;
	}
	  return true;
}
function isValidLanguageFileUploaded(filename) {
	 //making sure the user only uploads jpeg, jpg, gif files.
	var testStr = '.conf.CONF';
	var txt = filename;
	if (testStr.indexOf(txt.substring(txt.lastIndexOf('.'))) == -1) {
	  return false;
	}
	  return true;
}
function isValidVideoFileUploaded(filename) {
	 //making sure the user only uploads jpeg, jpg, gif files.
	var testStr = '.asx.ASX.asf.ASF.m1v.M1V.m2v.M2V.mpg.MPG.mpeg.MPEG.ogm.OGM.omf.OMF.rm.RM.vob.VOB.wmv.WMV';
	var txt = filename;
	if (testStr.indexOf(txt.substring(txt.lastIndexOf('.'))) == -1) {
	  return false;
	}
	  return true;
}

function popup_display(stage,mode,popupwidth,popupheight,id){
	var url = 'index.php?stage='+stage+'&mode='+mode;
	if(id != "")
		url = url + "&id="+ id;
	//var popupwindow= window.open(url,'_new','height='+popupheight+',width='+popupwidth+',status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,modal=yes');
	var popupwindow= window.showModalDialog(url,'_new','dialogWidth:'+popupwidth+'px;dialogHeight:'+popupheight+'px');

	
}

function popup_displayURL(stage,mode,popupwidth,popupheight,id){
	var url = 'index.php?stage='+stage+'&mode='+mode;
	if(id != "")
		url = url + "&pop=1&n_id="+ id;
	//var popupwindow= window.open(url,'_new','height='+popupheight+',width='+popupwidth+',status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,modal=yes');
	var popupwindow= window.showModalDialog(url,'_new','dialogWidth:'+popupwidth+'px;dialogHeight:'+popupheight+'px');

	
}

function window_display(url,popupwidth,popupheight){
	//var popupwindow= window.open(url,'_new','height='+popupheight+',width='+popupwidth+',status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,modal=yes');
	var popupwindow= window.showModalDialog(url,'_new','dialogWidth:'+popupwidth+'px;dialogHeight:'+popupheight+'px');
}

