function getEl(id) {
	return document.getElementById(id);
}

function fixImages(id) {
	if(id) {
		if(is.ie) {
			try { 
				document.getElementById(id).src = 'images/spacer.gif';
			}catch(er){
				alert('Error: ' + er +' : '+er.description );  
			}
		}
	}else {
		if (document.all && is.msWin) {
			var oImages = document.getElementsByTagName("img");
			for (var i=0;i<oImages.length;i++ ) {
			 if (oImages[i].className=='png') {
			   imageUrl = oImages[i].src;
			   oImages[i].src = 'images/spacer.gif';
			   oImages[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+imageUrl+"', sizingMethod='scale')";
			 }
			}
		}
	}
}
	

function checkFRM(frm,serial,onsubmit) {
	em = document.getElementById('email');
	
	valid = valideml(em);
	
	if(valid == 0) {
		alert('Please enter a correctly formatted email address (example@example.com)');
		em.focus();
		return false;
	}else if(valid < 0) {
		alert('Please enteryour email address');
		em.focus();
		return false;
	}
	
	if(onsubmit) {
		return true;
	}else {
		frm.submit();
	}
}
			

function validemail(val){
	
	if(val){

		var email = new String(val);
		var check1 = email.indexOf("@"); 	/* Check for an @ symbol*/
		var check2 = email.lastIndexOf("."); 	/* Check for a period   */
		var check3 = email.indexOf(" "); 	/* Check for spaces	*/

		if((check1 <= 0) || (check2 < 0)|| 		/* No @ or period */
		  (check1 > check2)||((check2-1)==check1)||	/* Make sure @ is after period, but not immediatly after*/
		  (email.substring(check1+1).indexOf("@")>-1)||	/* No spaces, no multiple @'s */
		  ((email.length-1)-check2<2) || (check3>-1)){			/* After period is 2 letters or more */
			alert("Please enter a VALID email.\nExample: user@isp.com\nCannot contain spaces.");
			return false;
		}
		return true;
	}else{
		alert("Please enter an email address.");
		return false;
	}
}
function valideml(obj){
	if(obj != '[object]' && obj != '[object HTMLInputElement]') {
		alert('Error: Email is not object -> ' + obj);
		return false;
	}
	if(obj.value){

		var email = new String(obj.value);
		var check1 = email.indexOf("@"); 	/* Check for an @ symbol*/
		var check2 = email.lastIndexOf("."); 	/* Check for a period   */
		var check3 = email.indexOf(" "); 	/* Check for spaces	*/

		if((check1 <= 0) || (check2 < 0)|| 		/* No @ or period */
		  (check1 > check2)||((check2-1)==check1)||	/* Make sure @ is after period, but not immediatly after*/
		  (email.substring(check1+1).indexOf("@")>-1)||	/* No spaces, no multiple @'s */
		  ((email.length-1)-check2<2) || (check3>-1)){			/* After period is 2 letters or more */
			return 0;
		}
		return 1;
	}else{return -1;}
}




function flAlert(msg) {
	alert(msg);
}

/*********************************************
* Embed swf movies that retain API capabilities in IE (dont use the "SWFObject()")
*/
	function activeEmbed(src,id,height,width,divid,zindex) {
		if(!height) {
			height = '100%';
		}
		if(!width) {
			width = '100%';
		}
		
		if(divid) {
			embd = '<div id="'+ divid + '"><embed height="' + height + '" width="' + width + '" src="' + src + '" menu="false" quality="high"  name="' + id + '"  wmode="transparent"  align="middle"  type="application/x-shockwave-flash" allowScriptAccess="sameDomain" pluginspage="http://www.macromedia.com/go/getflashplayer"/></div>';
		}else {
			embd = '<embed height="' + height + '" width="' + width + '" src="' + src + '" menu="false" quality="high" id="' + id + '"  name="' + id + '"  wmode="transparent"  align="middle"  type="application/x-shockwave-flash" allowScriptAccess="sameDomain" pluginspage="http://www.macromedia.com/go/getflashplayer"/>';
		}
		
		objd = '<object height="' + height + '" width="' + width + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"  id="' +  id + '" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" align="middle">';
			objd +=	'<param name="allowScriptAccess" value="sameDomain" />';
			objd +=	'<param name="movie" value="'+ src + '" />';
			objd +=	'<param name="menu" value="true" />';
			objd +=	'<param name="scale" value="noscale" />';
			objd +=	'<param name="quality" value="high" />';
			objd +=	'<param name="wmode" value="transparent" />';
			objd += embd;
		objd +=	'</object>';
		
		document.write(objd);
	}
	
	
	
	////////////////////////////////////////// FOR FLASH

	function setNsend(frm,userStr,splitVal,splitName) {
		
		// ARRANGE DATA /////////////////////
		// get the value types
		var userAr = new Array();
		var tempAr = new Array();
		
		tempAr = userStr.split(splitVal);
		
		for(var i in tempAr) {
			hash = tempAr[i].split(splitName);
			if(hash[0] && hash[1]) {
				userAr[hash[0]] = hash[1];
			}
		}
		// END ARRANGEMENT //////////////////
		
				
		
		
		// set the data in html fields and post it				
		for(var i in userAr) {
			//alert(i + ' --> ' + userAr[i]);
			try {
				targ = getEl(i);
			}catch(e) {
				alert('Unable to find element: ' + i);
			}
			
			if(targ) {
				if(i == 'secretkey') {
					targ.value = userAr[i]; //hex_md5(userAr[i]);
				}else {
					targ.value = userAr[i];
				}
			}
		}
		
		getEl(frm).submit();
		
		return true;
				
	}
	
	// api to show a flash loader..
	function processComplete(success,msg) {
		flash = flashAccess('flashMain');
		flash.processComplete(success,msg);
	}
	/*******************************************************
	* return a working call for the flash object
	*/
	function flashAccess(id) {
		if(navigator.appName.indexOf("Microsoft") != -1) {
			flash = window.eval(id);
		}else {
			flash = window.document.eval(id);
		}
		return flash;	
	}