// JavaScript Document
// Validations for admin side pages 
document.write("<script language='JavaScript' src='script/general.js'></script>");

//re_result
function dynamitere() {
	
		var err;	
		//alert("hai");
	    var url=document.getElementById("url").value;
	    var name=document.getElementById("name").value;
	    var email=document.getElementById("email").value;
		
	if(url=="")
	{
		err = "Please enter URL.";
		alert(err);
		document.getElementById("url").focus();
		return false;
	}
	if(name=="") 
	{
		err = "Please enter Name.";
		alert(err);
		document.getElementById("name").focus();
		return false;
	}
	if(email=="") 
	{
		err = "Please enter email id.";
		alert(err);
		document.getElementById("email").focus();
		return false;
	}
     var m = document.getElementById('email').value;
     var cnt=0,spc=0,dot=0;
     for(var i=1;i<=m.length;i++)
     {
          if(m.charAt(i)=="@")
              cnt++;
          if(m.charAt(i)==" ")
              spc++;
          if(m.charAt(i)==".")
              dot++;
     }
     lnm=m.length;
     if(cnt==0||cnt>1||spc!=0||dot==0 ||lnm<=2 )
     {
         alert("Invalid Email Address");
         document.getElementById('email').focus()
         return false;
	 }
	
var o=document.getElementById('url').value;	
var url='demore.htm?url=www.'+o;
//alert(url);
window.open(url,'DynamiteVideoDemo','titlebar=no,toolbar=no,location=no,top=0,left=0,width=' +screen.width+ ',height=' + screen.height);
document.form1.submit();
return true;
}


//sales_demo - fitness page
function dynamite1() {
	
		var err;	
		//alert("hai");
	    var url=document.getElementById("url").value;
	    var name=document.getElementById("name").value;
	    var email=document.getElementById("email").value;
		
	if(url=="")
	{
		err = "Please enter URL.";
		alert(err);
		document.getElementById("url").focus();
		return false;
	}
	if(name=="") 
	{
		err = "Please enter Name.";
		alert(err);
		document.getElementById("name").focus();
		return false;
	}
	if(email=="") 
	{
		err = "Please enter email id.";
		alert(err);
		document.getElementById("email").focus();
		return false;
	}
     var m = document.getElementById('email').value;
     var cnt=0,spc=0,dot=0;
     for(var i=1;i<=m.length;i++)
     {
          if(m.charAt(i)=="@")
              cnt++;
          if(m.charAt(i)==" ")
              spc++;
          if(m.charAt(i)==".")
              dot++;
     }
     lnm=m.length;
     if(cnt==0||cnt>1||spc!=0||dot==0 ||lnm<=2 )
     {
         alert("Invalid Email Address");
         document.getElementById('email').focus()
         return false;
	 }
	
var o=document.getElementById('url').value;	
var url='demo1.htm?url=www.'+o;	
//alert(url);
window.open(url,'DynamiteVideoDemo','titlebar=no,toolbar=no,location=no,top=0,left=0,width=' +screen.width+ ',height=' + screen.height);
document.form1.submit();
return true;
}

//real_estate demo
function dynamite2() {
	
		var err;	
		//alert("hai");
	    var url=document.getElementById("url").value;
	    var name=document.getElementById("name").value;
	    var email=document.getElementById("email").value;
		
	if(url=="")
	{
		err = "Please enter URL.";
		alert(err);
		document.getElementById("url").focus();
		return false;
	}
	if(name=="") 
	{
		err = "Please enter Name.";
		alert(err);
		document.getElementById("name").focus();
		return false;
	}
	if(email=="") 
	{
		err = "Please enter email id.";
		alert(err);
		document.getElementById("email").focus();
		return false;
	}
     var m = document.getElementById('email').value;
     var cnt=0,spc=0,dot=0;
     for(var i=1;i<=m.length;i++)
     {
          if(m.charAt(i)=="@")
              cnt++;
          if(m.charAt(i)==" ")
              spc++;
          if(m.charAt(i)==".")
              dot++;
     }
     lnm=m.length;
     if(cnt==0||cnt>1||spc!=0||dot==0 ||lnm<=2 )
     {
         alert("Invalid Email Address");
         document.getElementById('email').focus()
         return false;
	 }
	
var o=document.getElementById('url').value;	
var url='demo2.htm?url=www.'+o;	
//alert(url);
window.open(url,'DynamiteVideoDemo','titlebar=no,toolbar=no,location=no,top=0,left=0,width=' +screen.width+ ',height=' + screen.height);
document.form1.submit();
return true;
}

//general page demo
function dynamite3() 
{
		var err;	
		//alert("hai");
	    var url=document.getElementById("url").value;
	    var name=document.getElementById("name").value;
	    var email=document.getElementById("email").value;
	
	if(url=="")
	{
		err = "Please enter URL.";
		alert(err);
		document.getElementById("url").focus();
		return false;
	}
	if(name=="") 
	{
		err = "Please enter Name.";
		alert(err);
		document.getElementById("name").focus();
		return false;
	}
	if(email=="") 
	{
		err = "Please enter email id.";
		alert(err);
		document.getElementById("email").focus();
		return false;
	}
     var m = document.getElementById('email').value;
     var cnt=0,spc=0,dot=0;
     for(var i=1;i<=m.length;i++)
     {
          if(m.charAt(i)=="@")
              cnt++;
          if(m.charAt(i)==" ")
              spc++;
          if(m.charAt(i)==".")
              dot++;
     }
     lnm=m.length;
     if(cnt==0||cnt>1||spc!=0||dot==0 ||lnm<=2 )
     {
         alert("Invalid Email Address");
         document.getElementById('email').focus()
         return false;
	 }

var o=document.getElementById('url').value;	
var url='demo3.htm?url=www.'+o;	
//alert(url);
window.open(url,'Dynamitedisplay','titlebar=no,toolbar=no,location=no,top=0,left=0,width=' +screen.width+ ',height=' + screen.height);
document.form1.submit();
return true;
}

//demo page - free trial dynamitenetwork.com
function dynamite() 
{
		var err;	
		//alert("hai");
	    var url=document.getElementById("url").value;
	    var name=document.getElementById("name").value;
	    var email=document.getElementById("email").value;

	
	
	
	if(url=="")
	{
		err = "Please enter URL.";
		alert(err);
		document.getElementById("url").focus();
		return false;
	}
	if(name=="") 
	{
		err = "Please enter Name.";
		alert(err);
		document.getElementById("name").focus();
		return false;
	}
	if(email=="") 
	{
		err = "Please enter email id.";
		alert(err);
		document.getElementById("email").focus();
		return false;
	}
     var m = document.getElementById('email').value;
     var cnt=0,spc=0,dot=0;
     for(var i=1;i<=m.length;i++)
     {
          if(m.charAt(i)=="@")
              cnt++;
          if(m.charAt(i)==" ")
              spc++;
          if(m.charAt(i)==".")
              dot++;
     }
     lnm=m.length;
     if(cnt==0||cnt>1||spc!=0||dot==0 ||lnm<=2 )
     {
         alert("Invalid Email Address");
         document.getElementById('email').focus()
         return false;
	 }
var o=document.getElementById('url').value;	
var url='demo.htm?url=www.'+o;	
//alert(url);
window.open(url,'Dynamitedisplay','titlebar=no,toolbar=no,location=no,top=0,left=0,width=' +screen.width+ ',height=' + screen.height);
document.form1.submit();
return true;
}

// video code


function ParseParams() {
	var res=new Array();
	var href=new String(window.location.href);
	var qi=href.indexOf('?');
	if(qi!=-1) {
	
		var tail=new String(href.substr(qi+1));
		var params=tail.split('&');
		for(var i=0;i<params.length;i++) {
			
			if(params[i].indexOf('=')!=-1) {
				var split=params[i].split('=');
				res[split[0].toLowerCase()]=split[1];
			} else {
				res[params[i].toLowerCase()]='';
			}
		}
	}
	return res;
}
		var params=ParseParams();
		var url=params['url'];
		if(url.indexOf('http://')!=0) { url='http://'+url;}
			document.getElementById('demoFrame').src=url;


/* dynamiteVideo class
 */
var dynamitedisplay_Global;
function show() {
	dynamitedisplay_Global.Show();
}

function dynamitedisplay() {
	this.src="";
	this.width="";
	this.height="";	
	this.Position
	this.Location=new this.Point();
	this.Location.X=0;
	this.Location.Y=0;
	this.PositionMode='absolute';
	this.positionFrom='fromBottom';
	this.positionHorizontalFrom='fromLeft';
	this.ReferenceID=null;
	this.RequiredVersionMajor=9;
	this.RequiredVersionMinor=0;
	this.needFlashString="Flash Version "+this.RequiredVersionMajor+"."+this.RequiredVersionMinor+" is needed.<br/><a href='http://www.adobe.com/go/getflash/' target='_blank'>Get it here</a>";
	if(document.body.attachEvent) { this.isIE=true;} else { this.isIE=false;}
	this.ParseBrowser();
	this.backgroundImage='/images/transparent.gif';
	this.NeedsFix=false;
	this.WriteWrapper=true;
	this.FlashVars='';
	this.urlArray=null;
	this.anchorMode='static';
}

dynamitedisplay.prototype.Query=function(x) {
	if(this.urlArray==null) {
		var res=new Array();
		var href=new String(window.location.href);
		var qi=href.indexOf('?');
		if(qi!=-1) {
			var tail=new String(href.substr(qi+1));
			var params=tail.split('&');
			for(var i=0;i<params.length;i++) {
				if(params[i].indexOf('=')!=-1) {
					var split=params[i].split('=');
					res[split[0].toLowerCase()]=split[1];
				} else {
						res[params[i].toLowerCase()]='';
					}
				}
			}
		this.urlArray=res;
	}
	return this.urlArray[x];
}

dynamitedisplay.prototype.AddUrlVarToFlashVars=function(a) {
	this.AddVarToFlashVars(a,this.Query(a));
} 

dynamitedisplay.prototype.AddVarToFlashVars=function(n,v) {
	this.FlashVars=this.FlashVars+n+'='+v+'&';
}

dynamitedisplay.prototype.AddUrlVarToFlashVarsRenamed=function(a,name) {
	this.FlashVars=this.FlashVars+name+'='+this.Query(a)+'&';
}
dynamitedisplay.prototype.Point=function(x,y){
	this.X=x;
	this.Y=y;
}
dynamitedisplay.prototype.ParseBrowser=function() {
	this.isNetscape=false;
	this.isFirefox=false;
	this.isIE=false;
	this.isOpera=false;
	this.isSafari=false;
	this.appName=navigator.appName;
	this.appVersion=navigator.appVersion;
	if(this.appName=="Netscape"&&parseFloat(this.appVersion)>4.7) {
		var uai=navigator.userAgent.indexOf("Firefox");
		if(uai!=-1) {
			this.isFirefox=true
			this.browserVersionMaj=parseInt(navigator.userAgent.charAt(uai+8));
		} else {
			this.isNetscape=true;
			this.browserVersionMaj=parseFloat(this.appVersion);
		}
	} else {
		var uai=navigator.appVersion.indexOf("MSIE");
		if(uai!=-1) {
			this.isIE=true;
			var temp=navigator.appVersion.split("MSIE")
			this.appVersion=parseFloat(temp[1]);
			this.browserVersionMaj=parseInt(this.appVersion);
		} else {
			var uai=navigator.userAgent.indexOf("Opera");
			if(uai!=-1){
				this.isOpera=true;
				this.browserVersionMaj=parseInt(navigator.userAgent.charAt(uai+6));
			}
		}
	}
	if(document.compatMode=='CSS1Compat') {
		this.isCompatible=true;
	} else {
		this.isCompatible=false;
	}
}
dynamitedisplay.prototype.el=function(e) { return document.getElementById(e);}
dynamitedisplay.prototype.AnchorToObjectX=function(){
	if(this.isIE) {		
		window.attachEvent('onresize',AnchorResizedX);
		window.attachEvent('onload',AnchorResizedX);
	} else {
		window.addEventListener('load',AnchorResizedX,false);
		window.addEventListener('resize',AnchorResizedX,false);
	}
}

dynamitedisplay.prototype.Intialize=function() {
	dynamitedisplay_Global=this;
	if(this.anchorMode=='static')
	{
		this.positionMode='fixed';
		if(this.isIE) {
			if(this.appVersion!=7 || !this.isCompatible)	{
				this.positionMode='absolute';
				this.NeedsFix=true;
			}
		}
		if(this.isFirefox && this.browserVersionMaj<2) {
			this.positionMode='absolute';
			window.addEventListener('scroll',RestorePosition,false);
			window.addEventListener('size',RestorePosition,false);
	
		}
		
		this.WriteDiv();
	} else {
		this.positionMode='absolute';
		this.WriteDiv();
	}
		if(this.ReferenceID!=null && this.el(this.ReferenceID)) {

			this.AnchorToObjectX();
		}
}
dynamitedisplay.prototype.PlaceElement=function (o,s,l,t) {
	var obj=this.el(o); var src=this.el(s);
	var srcLoc=GetObjectPosition(src);
	var nl=l+srcLoc[0];
	var nt=t+srcLoc[1];
	obj.style.left=nl + 'px';
	obj.style.top= nt + 'px';
}
dynamitedisplay.prototype.CheckFlashVersion = function() {
	var maj=0;
	var min=0;
	if(navigator.plugins != null && navigator.plugins.length > 0) {
		if(navigator.plugins["Shockwave Flash"]) {
			var d=navigator.plugins["Shockwave Flash"].description;
			var a=d.split(" ");
			var version=a[2];
			var a1=version.split(".");
			maj=a1[0];
			min=a1[1];
			
		} 
	}
	else {
		try {
			// version will be set for 7.X or greater players
			var o = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		 	var d = o.GetVariable("$version");
			var a=d.split(" ");
			var version=a[1];
			var a1=version.split(",");
			maj=a1[0];
			min=a1[1];
		} catch (e) {
		}
	}
	if(maj>this.RequiredVersionMajor || (maj==this.RequiredVersionMajor && min>=this.RequiredVersionMinor)) { return true;}
	else {	return false;}
	
}
	

dynamitedisplay.prototype.GetObjectPosition=function(o) {
	var l,t;
	l=t=0;
	if(o.offsetParent) {
		l=o.offsetLeft;
		t=o.offsetTop;
		while((o=o.offsetParent)) {
			l+=o.offsetLeft;
			t+=o.offsetTop;
		}
	}
	return [l,t];
}

dynamitedisplay.prototype.Show=function(){
	this.el('dynamite_Container').style.display='none';
}

dynamitedisplay.prototype.GetObjectAbsoluteLocation=function(o) {
	var p=new this.Point(0,0);
	while(o!=null) {
		p.X+=o.offsetLeft;
		p.Y+=o.offsetTop;
		o=o.offsetParent
	}
	return p;
}

dynamitedisplay.prototype.GetObjectAbsoluteX=function(o) {
	var x;
	x=0;
	while(o!=null) {
		x+=o.offsetLeft;
		o=o.offsetParent
	}
	return x;
}

dynamitedisplay.prototype.GetObjectAbsoluteY=function(o) {
	var y;
	y=0;
	while(o!=null) {
		y+=o.offsetTop;
		o=o.offsetParent
	}
	return y;
}

dynamitedisplay.prototype.WriteStandardContainer= function(){
	document.write('<div id="dynamite_Container" style="z-index:1000;');
	this.WritePositionStyleInfo();
	document.write('z-index: 100;border: 0px; width:'+this.width+'px;height:'+this.height+';">');
}

dynamitedisplay.prototype.WritePositionStyleInfo=function() {
	document.write('position: '+this.positionMode+'; ');
	if(this.positionFrom=='fromBottom')
	{
		document.write('bottom: ');
	}
	else {document.write('top: ');}
	document.write(this.Location.Y+'px; ');
	if(this.positionHorizontalFrom=='fromLeft')
	{
		document.write('left: ');
	}
	else
	{
		document.write('right: ');
	}
	document.write(this.Location.X+'px;'); 
}
dynamitedisplay.prototype.WriteNeedFlashContainer= function(){
	document.write('<div id="dynamite_Container" style="');
	this.WritePositionStyleInfo();
	document.write('z-index: 100;border: 0px; width:'+this.width+'px; background-color:#FFF; padding:4px 4px 4px 4px; border:inset 3px #F00 ">');
}

dynamitedisplay.prototype.WriteDiv=function() {
	if(this.CheckFlashVersion()) {
		if(this.WriteWrapper) {
		
			this.WriteStandardContainer();
		}
		this.WriteMovieObject();
	}
	else {
		this.WriteNeedFlashContainer();
		this.WriteNeedFlash();
	}
	if(this.NeedsFix){
		this.FixIEFixed();
	}
	if(this.WriteWrapper) {
		document.write('</div>');
	}
}
dynamitedisplay.prototype.WriteNeedFlash=function() {
		document.write(this.needFlashString);
}
function AnchorResizedX() {
	var obj=dynamitedisplay_Global.el('dynamite_Container');
	var src=dynamitedisplay_Global.el(dynamitedisplay_Global.ReferenceID);
	var srcLoc=dynamitedisplay_Global.GetObjectAbsoluteX(src);
	var nl=video.Location.X+srcLoc;
	obj.style.left=nl + 'px';
}
var shown=0;
var lastNum=0;
function getIEFixHeight() {
	var loc;
	var scrollTop;
	var clientHeight;
  if( typeof( window.innerWidth ) == 'number' ) { //Non-IE
    clientHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
    clientHeight  = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible
    clientHeight  = document.body.clientHeight;
  }
	if( typeof( window.pageYOffset ) == 'number' ) {	//Netscape compliant
    scrollTop = window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { //DOM compliant
    scrollTop = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrollTop = document.documentElement.scrollTop;
  } else {scrollTop=0;}
	if(dynamitedisplay_Global.positionFrom=='fromBottom'){
		loc=scrollTop+clientHeight-dynamitedisplay_Global.Location.Y-dynamitedisplay_Global.el('dynamite_Container').clientHeight ;	
	} else {
		loc=scrollTop+dynamitedisplay_Global.Location.Y;
	}
	//if(shown<2 && lastNum!=loc) 
	//	{ alert(loc);shown++;lastNum=loc;}	
	return loc;
}

dynamitedisplay.prototype.WriteMovieObject=function()
{
	document.write('<object ');
	if(!this.WriteWrapper) { 
		document.write(' id="dynamite_Container"  style="');
		this.WritePositionStyleInfo();
		document.write('z-index: 100;"');
	}
	document.write(' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,19,0" width="');
	document.write(480+'px" height="'+360+'">\n');
	document.write('\t<param name="movie" value="'+this.src+'" />\n');
	document.write('\t<param name="quality" value="high" />\n');
	if(this.FlashVars!='') 
	{

		document.write('\t<param name="FlashVars" value="'+this.FlashVars+'"');
	}
	document.write('\t<param name="menu" value="false" />\n');
	document.write('\t<param name="wmode" value="transparent" />\n');
	document.write('\t<embed src="'+this.src+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="');
	document.write(360+'px" height="'+360+'" menu="false"');
	if(this.FlashVars!='') 
	{
		document.write('FlashVars="'+this.FlashVars+'"');
	}
	document.write('></embed>\n');
	document.write('</object>\n');
}

dynamitedisplay.prototype.FixIEFixed=function(){
	if(document.body.currentStyle['backgroundImage']=='none')
	{
		document.body.style.backgroundImage='url('+this.backgroundImage+')';
		document.body.style.backgroundRepeat='no-repeat';
		document.body.style.backgroundAttachment='fixed';
	}
	this.el('dynamite_Container').style.setExpression('top','getIEFixHeight()');
}

dynamitedisplay.prototype.FixFF15Position=function(){
	var scrollTop=	window.pageYOffset;
	var clientHeight=window.innerHeight;

	if(this.InitialHeight== undefined) { this.InitialHeight=this.el('dynamite_Container').clientHeight;}
	if(this.positionFrom=='fromBottom'){
		loc = scrollTop + clientHeight - 
				this.Location.Y-this.InitialHeight ;	
	} else {
		loc=scrollTop+dynamitedisplay_Global.Location.Y;
	}
	this.el('dynamite_Container').style.top=loc+'px';
}

function RestorePosition() {
	dynamitedisplay_Global.FixFF15Position();
}
//functon for lawers
function dynamitelaw() {
	
		var err;	
		//alert("hai");
	    var url=document.getElementById("url").value;
	    var name=document.getElementById("name").value;
	    var email=document.getElementById("email").value;
		
	if(url=="")
	{
		err = "Please enter URL.";
		alert(err);
		document.getElementById("url").focus();
		return false;
	}
	if(name=="") 
	{
		err = "Please enter Name.";
		alert(err);
		document.getElementById("name").focus();
		return false;
	}
	if(email=="") 
	{
		err = "Please enter email id.";
		alert(err);
		document.getElementById("email").focus();
		return false;
	}
     var m = document.getElementById('email').value;
     var cnt=0,spc=0,dot=0;
     for(var i=1;i<=m.length;i++)
     {
          if(m.charAt(i)=="@")
              cnt++;
          if(m.charAt(i)==" ")
              spc++;
          if(m.charAt(i)==".")
              dot++;
     }
     lnm=m.length;
     if(cnt==0||cnt>1||spc!=0||dot==0 ||lnm<=2 )
     {
         alert("Invalid Email Address");
         document.getElementById('email').focus()
         return false;
	 }
	
var o=document.getElementById('url').value;	
var url='demolaw.htm?url=www.'+o;	
//alert(url);
window.open(url,'DynamiteVideoDemo','titlebar=no,toolbar=no,location=no,top=0,left=0,width=' +screen.width+ ',height=' + screen.height);
document.form1.submit();
return true;
}







