<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 124;
var cTextAddress ='',vTotLine=0;
var vByte = 0;
// -----------------------------------------------------------------------------
 IsIE = (document.all && navigator.userAgent.search(/MSIE/i) != -1)|| false;
// -->

function updateValues(from,to){
	if(from.nodeName == 'SELECT'){
		var select_list_selected_index = from.selectedIndex; 
		var text = from.options[select_list_selected_index].id; 
		text	=	text.replace("options_","");
		document.getElementById(to).value = text;
	}else{
		document.getElementById(to).value = from.value;
	}
}
function validateEmail(str){
var emailRegEx = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
if(str.match(emailRegEx)){
	return true;
}else{
return false;
}
}
function loadRenderImage(pmObj, pmLength)
{
	try {
	var vLength = pmObj.value.length;
	//alert(vLength)
	var vString = pmObj.value;
	var vByte = 0;
	var vCharacter = vString;
	var vLine  = 0;
	var vFlag=0;
	var vNextLineCount,vData='';
	var vNextChar='';
	var vChar1;
	
	if(pmLength>0 && pmObj.name!="emailAddress" && pmObj.name!="website")
	{
		vCharacter = '';
		for(vIndex=0;vIndex<vLength;vIndex++)
		{
			vChar = vString.charCodeAt(vIndex);
			if(vChar>255)
				vByte = vByte+2;
			else	
				vByte = vByte+1;
			if(vByte<=pmLength)
				vCharacter = vCharacter+ vString.charAt(vIndex);
 		}
 	}
	
	if(pmObj.name=="emailAddress"  && vLength>0)
	{
		vCharacter = '';
		if(!validateEmail(vString))
		{
			document.getElementById("erremail").style.display="inline";
			return false;
		}
		for(vIndex=0;vIndex<vLength;vIndex++)
		{
			vChar = vString.charCodeAt(vIndex);
			if(vChar>32 && vChar<127)
			{
				vByte = vByte+1;
			}else {
				document.getElementById("erremail").style.display="inline";
				return false;
			}
			if(vByte<=pmLength)
			vCharacter = vCharacter+ vString.charAt(vIndex);
		}
		document.getElementById("erremail").style.display="none";
 	}
	else
	{
		document.getElementById("erremail").style.display="none";
	}
	
	if(pmObj.name=="website"  && vLength>0)
	{
		vCharacter = '';
		for(vIndex=0;vIndex<vLength;vIndex++)
		{
			vChar = vString.charCodeAt(vIndex);
			if(vChar>32 && vChar<127)
			{
				vByte = vByte+1;
			}else {
				document.getElementById("errweb").style.display="inline";
				return false;
			}
			if(vByte<=pmLength)
			vCharacter = vCharacter+ vString.charAt(vIndex);
 		}
		document.getElementById("errweb").style.display="none";
		
 	}
	else
	{
		document.getElementById("errweb").style.display="none";
	}
	
	if(trim(vCharacter.toUpperCase()) =='TEL:' || trim(vCharacter.toUpperCase()) =='FAX:' || trim(vCharacter.toUpperCase()) =='TEL' || trim(vCharacter.toUpperCase()) =='FAX')
		vCharacter='';
		//alert(vCharacter)
	document.getElementById("VisitingCardMaker").update(pmObj.name, vCharacter);
	document.getElementById("VisitingCardMaker").update("title", document.frmCard.title.value);
	}
  catch(e) {
    //alert(e);		// Return error message.
  }
}
function trim(pmString)
{
	/* Function will remove the left and right white spaces within the string */
	return pmString.replace( /^ +/, "" ).replace( / +$/, "" );
}
 
 
function validate(pmMsg)
{ 
	alert('its enetr');
	/*var selects = document.getElementsByTagName('select');
 	if(document.getElementById("chkproof").checked)
	{
		 window.parent.document.getElementById('swf').style.visibility='visible';
		 window.parent.document.frmCard.submit();
		 window.parent.document.getElementById('lightwindow_container').style.display='none';
		 window.parent.document.getElementById('lightwindow_overlay').style.display='none';
	}
	else
		alert(window.parent.document.getElementById("hidMsg").value);*/
}
function validate1(vEvent,Width,Height,Path)
{
		var selects = document.getElementsByTagName('select');
		
			for(var i = 0; i < selects.length; i++) 
			{
				var	Ids	=	selects[i].id;
				var where_is_att=Ids.indexOf('att');
				if (where_is_att == 0)
				{
						var value	=	selects[i].value;
						if (value == "")
						{
							document.getElementById('error').style.display	=	"block";
							return false;
						}
						else
						{
							document.getElementById('error').style.display	=	"none";//getRenderedImage();
							loadGetPopupPage(vEvent,Width,Height,Path);
						}

				}
				//alert(selects[i].id);
			}
			document.getElementById('swf').style.visibility='hidden';
			return;
}

function getRenderedImage()
{
		document.getElementById('swf').style.visibility='hidden';
		//document.getElementById('saravanan').style.visibility='hidden';
 		document.getElementById("imgdata").value = document.getElementById("VisitingCardMaker").getxml();
		document.getElementById("imagedata").value = document.getElementById("VisitingCardMaker").getImage();
  		return true;
}	
 
//function loadSWF(pmSwfPath, pmWidth, pmHeight)
function loadSWF(pmSwfPath,pmXmlPath,pmWidth ,pmHeight)
{
	
	// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
	var hasProductInstall = DetectFlashVer(6, 0, 65);
	//pmWidth = 550;
	//pmHeight = 350;
	// Version check based upon the values defined in globals
	var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	if ( hasProductInstall && !hasRequestedVersion ) {
		// DO NOT MODIFY THE FOLLOWING FOUR LINES
		// Location visited after installation is complete if installation is required
		var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
		var MMredirectURL = window.location;
		document.title = document.title.slice(0, 47) + " - Flash Player Installation";
		var MMdoctitle = document.title;
		AC_FL_RunContent(
			"src", pmSwfPath+"playerProductInstall",
			"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
			"width", pmWidth,
			"height", pmHeight,
			"align", "middle",
			"id", "VisitingCardMaker",
			"quality", "high",
			"bgcolor", "#ffffff",
			"name", "VisitingCardMaker",
			"allowScriptAccess","sameDomain",
			"type", "application/x-shockwave-flash",
			"pluginspage", "http://www.adobe.com/go/getflashplayer"
		);
	} else if (hasRequestedVersion) {
		// if we've detected an acceptable version
		// embed the Flash Content SWF when all tests are passed
		AC_FL_RunContent(
		"src", pmSwfPath+"VisitingCardMaker",
		"flashvars","endPointURI="+pmXmlPath,
		"width", pmWidth,
		"height", pmHeight,
		"align", "middle",
		"id", "VisitingCardMaker",
		"quality", "high",
		"bgcolor", "#ffffff", 
		"name", "VisitingCardMaker",
		"allowScriptAccess","sameDomain",
		"type", "application/x-shockwave-flash",
		"pluginspage", "http://www.adobe.com/go/getflashplayer"
	);
	} else {  // flash is too old or we can't detect the plugin
		var alternateContent = 'Alternate HTML content should be placed here. '
		+ 'This content requires the Adobe Flash Player. '
		+ '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
	document.write(alternateContent);  // insert non-flash content
	}	
}

function getPageSize ()
{
	var vXscroll,vYscroll;
	if(window.innerHeight && window.scrollMaxY)
	{
		vXscroll = document.body.scrollWidth;
		vYscroll = window.innerHeight + window.scrollMaxY;
	}
	else if(document.body.scrollHeight > document.body.offsetHeight)
	{
		vXscroll = document.body.scrollWidth;
		vYscroll = document.body.scrollHeight;
	}
	else
	{
		vXscroll = document.body.offsetWidth;
		vYscroll = document.body.offsetHeight;
	}
	
	var vWindowWidth,vWindowHeight;
	if(self.innerHeight)
	{
		vWindowWidth = self.innerWidth;
		vWindowHeight = self.innerHeight;
	}
	else if(document.documentElement && document.documentElement.clientHeight)
	{
		vWindowWidth  = document.documentElement.clientWidth;
		vWindowHeight = document.documentElement.clientHeight;
	}
	else if(document.body)
	{
		vWindowWidth  = document.body.clientWidth;
		vWindowHeight = document.body.clientHeight;
	}
	var vPageHeight,vPageWidth;
	
	if(vYscroll < vWindowHeight) vPageHeight = vWindowHeight;
	else vPageHeight = vYscroll;
	
	if(vXscroll < vWindowWidth) vPageWidth = vWindowWidth;
	else vPageWidth = vXscroll;
	return {vPageWidth:vPageWidth, vPageHeight:vPageHeight, vWindowWidth:vWindowWidth, vWindowHeight:vWindowHeight};
}
function loadGetPasswordPage(ev,pmHeight,pmWidth,vSrc)
{
	
	if(ev)
	{
		if (ev.pageX)
		{//Moz
			posx=ev.pageX;
			posy=ev.pageY
		}
		else if(ev.clientX)
		{//IE
			posx=ev.clientX+document.body.scrollLeft;
			posy=ev.clientY+document.body.scrollTop;
			
		}
		else
		{
			return false
		}//old browsers
		vWidth=pmWidth.split("px");
		vheight=pmHeight.split("px");
		posx=(posx-vWidth[0])+60
		vW=vWidth[0]-25
		vH=vheight[0]-25
		posy=posy+20
		posx=posx+"px";
		posy=posy+"px";
	}
	vBackground = document.createElement('div');
	vBackground.id ='divParentDigi'
	vPageSize = getPageSize();
	vWdt=vPageSize.vPageWidth+35
	vBackground.style.width 	= vWdt+"px"; 
	vBackground.style.height 	= vPageSize.vPageHeight+"px"; 
	vBackground.style.left 	= "0px"; 
	vBackground.style.top 	= "0px"; 	
	
	vBackground.className 	= "popupBackgroundSafari";
	//parent.document.body = return false;
	//alert(vBackground.innerHTML)
	
	vPosx	= (vPageSize.vWindowWidth/2)-(vWidth[0]/2)
	vPosy	= (vPageSize.vWindowHeight/2)-(vheight[0]/2)
	vPosx 	= vPosx+'px'; 
	vPosy 	= vPosy+'px';

	vPanel = document.createElement('div');
	vPanel.id ='divPanel'
	vPanel.style.width 	= pmWidth; 
	vPanel.style.height = pmHeight; 
	vPanel.style.left 	= vPosx; 
	vPanel.style.top 	= vPosy;
	vPanel.style.position='fixed'
	//vPanel.style.className='sample'
	
	vPanel.innerHTML	= '<div id="divForgetPass" style="background-color:#FFFFFF; height:pmHeight; width:pmWidth; top:vPosy; left:vPosx" align="center"><div align="right"><span onclick="closeGetPasswordPage()" style="cursor:pointer;">X</span>&nbsp;&nbsp;</div><div id="loadIframe" align="center" style="height:325px; width:525px;"><iframe src="'+vSrc+'" frameborder="0" height="'+vH+'" width="'+vW+'"></iframe></div></div>'
	document.body.appendChild(vBackground);
	setTimeout(function (){document.body.appendChild(vPanel)},1000);;
}
function closeGetPasswordPage()
{
	if(document.getElementById('divPanel'))
		document.body.removeChild(document.getElementById('divPanel'));
	if(document.getElementById('divParentDigi'))
		document.body.removeChild(document.getElementById('divParentDigi'));
}



// added by saravanan

IsIE = (document.all && navigator.userAgent.search(/MSIE/i) != -1)|| false;

function getPageSize ()
{
	var vXscroll,vYscroll;
	if(window.innerHeight && window.scrollMaxY)
	{
		vXscroll = document.body.scrollWidth;
		vYscroll = window.innerHeight + window.scrollMaxY;
	}
	else if(document.body.scrollHeight > document.body.offsetHeight)
	{
		vXscroll = document.body.scrollWidth;
		vYscroll = document.body.scrollHeight;
	}
	else
	{
		vXscroll = document.body.offsetWidth;
		vYscroll = document.body.offsetHeight;
	}
	
	var vWindowWidth,vWindowHeight;
	if(self.innerHeight)
	{
		vWindowWidth = self.innerWidth;
		vWindowHeight = self.innerHeight;
	}
	else if(document.documentElement && document.documentElement.clientHeight)
	{
		vWindowWidth  = document.documentElement.clientWidth;
		vWindowHeight = document.documentElement.clientHeight;
	}
	else if(document.body)
	{
		vWindowWidth  = document.body.clientWidth;
		vWindowHeight = document.body.clientHeight;
	}
	var vPageHeight,vPageWidth;
	
	if(vYscroll < vWindowHeight) vPageHeight = vWindowHeight;
	else vPageHeight = vYscroll;
	
	if(vXscroll < vWindowWidth) vPageWidth = vWindowWidth;
	else vPageWidth = vXscroll;
	return {vPageWidth:vPageWidth, vPageHeight:vPageHeight, vWindowWidth:vWindowWidth, vWindowHeight:vWindowHeight};
}

function loadGetPopupPage(ev,pmHeight,pmWidth,vSrc)
{
	//document.getElementById('swf').style.display = "none";
	if(ev)
	{
		if (ev.pageX)
		{//Moz
			posx=ev.pageX;
			posy=ev.pageY
		}
		else if(ev.clientX)
		{//IE
			posx=ev.clientX+document.body.scrollLeft;
			posy=ev.clientY+document.body.scrollTop;
		}
		else
		{
			return false
		}//old browsers
		vWidth=pmWidth.split("px");
		vheight=pmHeight.split("px");
		posx=(posx-vWidth[0])+75
		vW=vWidth[0]-25
		vH=vheight[0]-25
		posy=posy+20
		posx=posx+"px";
		posy=posy+"px";
	}
	vBackground = document.createElement('div');
	vBackground.id ='divParentDigi'
	vPageSize = getPageSize();
	vWdt=vPageSize.vPageWidth+35
	vBackground.style.width 	= vWdt+"px"; 
	vBackground.style.height 	= vPageSize.vPageHeight+"px"; 
	vBackground.style.left 	= "0px"; 
	vBackground.style.top 	= "0px"; 	
	//document.getElementById('header-top').className = "popupBackgroundSafari";
	vBackground.className 	= "popupBackgroundSafari";
	
	vPosx	= (vPageSize.vWindowWidth/2)-(vWidth[0]/2)
	vPosy	= (vPageSize.vWindowHeight/2)-(vheight[0]/2)
	vPosx 	= vPosx+'px'; 
	vPosy 	= vPosy+'px';

	vPanel = document.createElement('div');
	vPanel.id ='divPanel'
	vPanel.style.width 	= pmWidth; 
	vPanel.style.height = pmHeight; 
	vPanel.style.left 	= vPosx; 
	vPanel.style.top 	= vPosy;
	vPanel.style.position='fixed'
	
	vPanel.innerHTML	= '<div id="divForgetPass"></div><div id="loadIframe" align="center" style="height:'+vH+'px; width:'+vW+'px;"><iframe src="'+vSrc+'" frameborder="0" height="'+vH+'" width="'+vW+'"></iframe></div></div>'
	document.body.appendChild(vBackground);
	setTimeout(function (){document.body.appendChild(vPanel)},1000);;
}
function closeGetPopupPage()
{
	//document.getElementById('swf').style.display = "block";
	document.getElementById('swf').style.visibility='visible';
	if(document.getElementById('divPanel'))
		document.body.removeChild(document.getElementById('divPanel'));
	if(document.getElementById('divParentDigi'))
		document.body.removeChild(document.getElementById('divParentDigi'));
}
  
function isURL(s) {
 	var regexp = /^http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
 	return regexp.test(s);
}	
