var domain = 'http://www.lyriczz.com';
var dir = '';
var publickey = '6LcLpwIAAAAAAPm3MCFXs3XQRT7gEiyFQmeiYy29';
var theme = 'clean'; //Our captcha theme color

/*function initTinyMCE() {
    tinyMCE.init({
    entity_encoding : "named",
    mode : "textareas",
    theme : "advanced",
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,cut,copy,paste,pastetext,pasteword,|,undo,redo,|cleanup,code,|,insertdate,inserttime,preview,|,forecolor",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
	theme_advanced_buttons4 : "",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_path_location : "bottom",
	theme_advanced_resizing : true,
    cleanup_on_startup : true,
    cleanup: true,
	width : '90%',
	height : '200'
    });
}
initTinyMCE();*/
function ValidateName (str, divID)
{


	if(str.length > 20)
	{
		document.getElementById(divID).innerHTML = "<font color='red'>Max 20 characters</font>";
		return false;
	}
	
	if(str.length == 0)
	{
		document.getElementById(divID).innerHTML = "<font color='red'>This field cannot be left empty!</font>";
		return false;
	}

	document.getElementById(divID).innerHTML = "&nbsp;";
	
 	return true;
	
}
function RegenerateForm2(param)
{
//Destoy any old Captcha data we had.
	Recaptcha.destroy(); 

	//Clear the DIV tag contents before we load it up
	document.getElementById("SendLyric").innerHTML = "";
	
	//Create a New XMLhttprequest
	var req = createXHR();
	
	//Once the webserver is ready, try creating our object
	req.onreadystatechange = function()
	{
		if (req.readyState == 4 && req.status == 200 && req.responseText) 
		{
			document.getElementById("SendLyric").innerHTML = req.responseText;
		
			//Try loading up our captcha form
			try {
				Recaptcha.create(publickey,
				"SLrecaptcha", {
				theme: theme,
				callback: Recaptcha.focus_response_field
				});
			}
			catch (e) {
			  document.getElementById("SLrecaptcha").innerHTML = e +
             "Cannot Create Captcha Form! - If this problem continues, please contact us.";
            }
			
		}
	};
	
	//Send out parameters to our script
    req.open("GET", "../../../sendlyriczz.php?"+param+"");
	req.send("");
}
function RegenerateForm(param)
{
	
	//Destoy any old Captcha data we had.	
	Recaptcha.destroy(); 
	
	//Clear the DIV tag contents before we load it up
	document.getElementById("RecommndLyric").innerHTML = "";

	//Create a New XMLhttprequest
	var req = createXHR();
	
	//Once the webserver is ready, try creating our object
	req.onreadystatechange = function() 
	{
		if (req.readyState == 4 && req.status == 200 && req.responseText) 
		{ 
			document.getElementById("RecommndLyric").innerHTML = req.responseText;
			
			//Try loading up our captcha form
			try {
				Recaptcha.create(publickey,
				"recaptcha", {
				theme: theme,
				callback: Recaptcha.focus_response_field
				});
			}
			catch (e) {
			  document.getElementById("recaptcha").innerHTML = e +
             "Cannot Create Captcha Form! - If this problem continues, please contact us.";
            }
		}
	};
	
	//Send out parameters to our script
    req.open("GET", "../../../recommend.php?"+param+"");
	req.send("");

}


function checkFields()
{

	var error = '';
	

	 if(!ValidateName (document.forms.RecommendFreind.name.value, 'NameStatus', error))
	 {
		error = true;
	 }	
	 
	 if(!ValidateName (document.forms.RecommendFreind.friendname.value, 'FNameStatus', error))
	 {
		error = true;
	 }
	 
	 if(!ValidateEmail (document.forms.RecommendFreind.email.value))
	 {
		error = true;
	 }	
	
	if(document.forms.RecommendFreind.recaptcha_response_field.value == '')
	{
		document.getElementById('Status').innerHTML = "<font color='red'>Please fill out the captcha image!</font>";
		error = true;
	}else{

		document.getElementById('Status').innerHTML = "&nbsp;";
	}	

		

	 
	 if (error == false)
	 {
	 
		 makeRequest(xmlHttp, '../../../recommend.php', 'rbcontent', 'POST', getFormValues3(document.forms.RecommendFreind));
	 
	 }

}

function checkFields2()
{

	var error = '';

	 if(!ValidateEmail (document.forms.sendlyric.email.value))
	 {
		error = true;
	 }	

	 if(document.forms.sendlyric.recaptcha_response_field.value == '')
	{
		document.getElementById('Status').innerHTML = "<font color='red'>Please fill out the captcha image!</font>";
		error = true;
	}else{

		document.getElementById('Status').innerHTML = "&nbsp;";
	}	
	 
	 if (error == false)
	 {
		makeRequest(xmlHttp, '../../../sendlyriczz.php', 'rbcontent', 'POST', getFormValues3(document.forms.sendlyric));
		
	 }		
		
}

function timedwindow()
{
	var x=setTimeout("toggle('SendLyric');",5000)
	var y=setTimeout("toggle('layer1');",5000)

}

function ValidateEmail (str)
{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var error = false;
		if (str.indexOf(at)==-1){
		   document.getElementById("inf_email").innerHTML = "<font color='red'>Invalid E-mail</font>";
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   document.getElementById("inf_email").innerHTML = "<font color='red'>Invalid E-mail</font>";
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   document.getElementById("inf_email").innerHTML = "<font color='red'>Invalid E-mail</font>";
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   document.getElementById("inf_email").innerHTML = "<font color='red'>Invalid E-mail</font>";
			return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   document.getElementById("inf_email").innerHTML = "<font color='red'>Invalid E-mail</font>";
			return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   document.getElementById("inf_email").innerHTML = "<font color='red'>Invalid E-mail</font>";
			return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   document.getElementById("inf_email").innerHTML = "<font color='red'>Invalid E-mail</font>";
			return false
		 }
		 
		 document.getElementById("inf_email").innerHTML = "&nbsp;";
 		 return true					
	}

  function ValidateSubmit(str) {

  
	if(str.length != 0)
	{
  
  
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail")
		    return false
		 }
		 

 		 return true	
	}
		 
}	
	
	
function createXHR() 
{
    if (window.XMLHttpRequest)
        return req = new XMLHttpRequest();
    else if(window.ActiveXObject)
        return req = new ActiveXObject("MSXML2.XMLHTTP.3.0");
}

//Do we need this?
var xmlHttp = createXHR();


function builddimdiv() 
{

document.write('<div id="layer1" style="display:none;position:absolute;bottom:0;left:0;width:'+
    window.screen.width + 'px;;height:' + window.screen.height +'px;z-index:10;background-color:#000;-moz-opacity: 0.8;opacity:.80;filter: alpha(opacity=80);min-height: 0;"></div>');

}

//Build our Dim DIV - This generate our nice dark background
builddimdiv();


function CreateDiv (DIVName, DIVHeight, DIVWidth, ZIndex, Left) 
{
	//var width = window.screen.width - DIVHeight;
	//var height = window.screen.height - DIVWidth;
	
	var w_height = ""+DIVHeight+"px";
	var w_width = ""+DIVWidth+"px";
	
	var Div = document.createElement("div");

	Div.setAttribute('id', DIVName);
	Div.style.display = "none";
	Div.style.width = w_width;
	Div.style.height = w_height;
	Div.style.position = "absolute";
	Div.style.backgroundColor = "#C0D5E3";
	Div.style.left = Left;
	Div.style.top= "10%";
	Div.style.overflow = "auto";
	Div.style.zIndex = ZIndex;
	//document.write(Div);
	document.body.appendChild(Div);
	
	return Div;
}

function removeDiv(div) 
{
    if(typeof div == 'string') div = document.getElementById(div);
    if(div && div.parentNode)div.parentNode.removeChild(div);
}



function loadSendLyriczz(param) 
{

	//Create our DIV
	CreateDiv ('SendLyric', '500', '600', '20', '25%');

	//Display a loading Image while executing this function
	displayLoadingData('SendLyric');

	//Assign these two objects to a variable
	var obj = document.getElementById('SendLyric');
	var layer = document.getElementById('layer1');
	
	//Toggle these two Div Tags to be shown
	toggle('layer1');
	toggle('SendLyric');

	//Destoy any old Captcha data we had.
	Recaptcha.destroy(); 

	//Clear the DIV tag contents before we load it up
	document.getElementById("SendLyric").innerHTML = "";
	
	//Create a New XMLhttprequest
	var req = createXHR();
	
	//Once the webserver is ready, try creating our object
	req.onreadystatechange = function()
	{
		if (req.readyState == 4 && req.status == 200 && req.responseText) 
		{
			document.getElementById("SendLyric").innerHTML = req.responseText;
		
			//Try loading up our captcha form
			try {
				Recaptcha.create(publickey,
				"SLrecaptcha", {
				theme: theme,
				callback: Recaptcha.focus_response_field
				});
			}
			catch (e) {
			  document.getElementById("SLrecaptcha").innerHTML = e +
             "Cannot Create Captcha Form! - If this problem continues, please contact us.";
            }
			
		}
	};
	
	//Send out parameters to our script
    req.open("GET", "../../../sendlyriczz.php?"+param+"");
	req.send("");
}

function loadRecommndLyric(param)
{
	//Create our DIV
	CreateDiv ('RecommndLyric', '500', '600', '20', '25%');

	//Display a loading Image while executing this functio
	displayLoadingData('RecommndLyric');

	//Assign these two objects to a variable
	var obj = document.getElementById('RecommndLyric');
	var layer = document.getElementById('layer1');
	
	//Toggle these two Div Tags to be shown
	toggle('layer1');
	toggle('RecommndLyric');

	//Destoy any old Captcha data we had.	
	Recaptcha.destroy(); 
	
	//Clear the DIV tag contents before we load it up
	document.getElementById("RecommndLyric").innerHTML = "";

	//Create a New XMLhttprequest
	var req = createXHR();
	
	//Once the webserver is ready, try creating our object
	req.onreadystatechange = function() 
	{
		if (req.readyState == 4 && req.status == 200 && req.responseText) 
		{ 
			document.getElementById("RecommndLyric").innerHTML = req.responseText;
			
			//Try loading up our captcha form
			try {
				Recaptcha.create(publickey,
				"recaptcha", {
				theme: theme,
				callback: Recaptcha.focus_response_field
				});
			}
			catch (e) {
			  document.getElementById("recaptcha").innerHTML = e +
             "Cannot Create Captcha Form! - If this problem continues, please contact us.";
            }
		}
	};
	
	//Send out parameters to our script
    req.open("GET", "../../../recommend.php?"+param+"");
	req.send("");
}


function LoadEditor(param) 
{
	//Display a loading Image while executing this functio
	displayLoadingData('form');
	
	//Create our DIV
	CreateDiv ('form', '450', '400', '20', '20%');

	//Assign these two objects to a variable
	var obj = document.getElementById('form');
	var layer = document.getElementById('layer1');
	
	//Toggle these two Div Tags to be shown
	toggle('layer1');
	toggle('form');
	 
	//Destoy any old Captcha data we had.	 
	Recaptcha.destroy();
	
	//Clear the DIV tag contents before we load it up
	document.getElementById("form").innerHTML = "";
	
	//Remove the TinyMCEeditor from the DIV tag - NOT NEED IF WE DO NOT LOAD UP THE TINYMCE EDITOR
	/*try {
		tinyMCE.idCounter = 0;
		tinyMCE.execCommand('mceRemoveControl', false, "elm1");
	}
	catch (e) {
		document.getElementById("form").innerHTML = e +
		"Cannot Remove TinyMCE editor! - Internal Server Error";
	}*/
	
	//Create a New XMLhttprequest
	var req = createXHR();
	
	//Once the webserver is ready, try creating our object
	req.onreadystatechange = function() 
	{
		if (req.readyState == 4 && req.status == 200 && req.responseText) 
		{
			document.getElementById("form").innerHTML = req.responseText;
			
			//Load up our TinyMCE editor - NOT NEEDED IF WE DO NOT LOAD UP THE TINYMCE EDITOR
			/*try {
				tinyMCE.idCounter = 0;
				//tinyMCE.execCommand('mceAddControl', false, "elm1");
				tinyMCE.execCommand('mceFocus', false, "elm1");
			}
			catch (e) {
				document.getElementById("form").innerHTML = e +
				"Cannot Remove TinyMCE editor! - Internal Server Error";
			}*/
			
			//Try loading up our captcha form
			try {
				Recaptcha.create(publickey,
				"recaptcha", {
				theme: theme,
				callback: Recaptcha.focus_response_field
				});
			}
			catch (e) {
			
			  document.getElementById("recaptcha").innerHTML = e +
             "Cannot Create Captcha Form! - If this problem continues, please contact us.";
            }
		}
	};

	//Send out parameters to our script
    req.open("GET", "../../../editlyric.php?"+param+"");
	req.send("");
}

function makeRequest(xmlhttp, scriptName, objID, method, params) {
  var obj = document.getElementById(objID);
  
  displayLoadingData(obj);
  if (method == "GET") {
    xmlhttp.open("GET", scriptName + "?" + params, true);
    xmlhttp.onreadystatechange = function () {
      if (xmlhttp.readyState == 4) {
        if (xmlhttp.responseText.indexOf('LaunchPage=') == 0)
          launchPage(xmlhttp.responseText);
        else
          obj.innerHTML = xmlhttp.responseText;
      }
    }
    xmlhttp.send(null);
  }
  else {
    xmlhttp.open("POST", scriptName, true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    xmlhttp.onreadystatechange = function () {
      if (xmlhttp.readyState == 4) {

        if (xmlhttp.responseText.indexOf('LaunchPage') == 0)
          launchPage(xmlhttp.responseText);
        else
          obj.innerHTML = xmlhttp.responseText;
      }
	  
    }
    xmlhttp.send(params);
  }
  
}



function displayLoadingData(obj) {
  obj.innerHTML = '<p align="center"> <img name="loading" src="http://xblader.net/lyriczz/img/loader.gif"  algin="bottom"><br> <b>Loading...</b></p>';
}


function getData(xmlHttp, section, divID, params) {
  makeRequest(xmlHttp, ''+section+'.php', ''+divID+'', 'GET', params);
}

function getPage(xmlHttp, section, divID, params) {

	var obj = document.getElementById('form');
	var layer = document.getElementById('layer1');
	
	 toggle('layer1');
	 toggle('form');
	 

	 
	 

  makeRequest(xmlHttp, ''+section+'.php', ''+divID+'', 'GET', params);
}


function getFormValues(theform) {
  var str = "";

  for (var i = 0; i < theform.elements.length; i ++) {
	str += theform.elements[i].name + "=" +  theform.elements[i].value + "&";
  }

  return str;
}

function getFormValues3(theform) {
  
  var str = "";
  
  for (var i = 0; i < theform.elements.length; i ++) {
    str += theform.elements[i].name + "=" + escape(theform.elements[i].value) + "&";
  }
 
  return str;
}


function postForm(xmlHttp, section, params) {
  makeRequest(xmlHttp, ''+section+'.php', 'EmailLyriczz', 'POST', params);
}

function getFormValues2(theform) {
  var str = "";
  
  for (var i = 0; i < theform.elements.length; i ++) {
    if (theform.elements[i].name == 'Action')
        str += theform.elements[i].name + "=" + escape(theform.elements[i].value) + "&";
    else
      if (theform.elements[i].checked == true)
        str += theform.elements[i].name + "=Yes&";
  }
  
  return str;
}


function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {	   
		el.style.display = 'none';
		document.getElementsByTagName("body")[0].style.overflow = "scroll";
	}
	else {
		el.style.display = '';
		document.getElementsByTagName("body")[0].style.overflow = "hidden";
	}
}



/*  
Script made by Martial Boissonneault � 2001-2002 http://getElementById.com/
This script may be used and changed freely as long as this msg is intact
Visit http://getElementById.com/ for more free scripts and tutorials.
*/
var ie5 = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);
var divs = document.getElementsByTagName("div");

nStart=0.99   // Opacity to start and onmouseout
nOver=0.30   // Opacity onmouseover

function ChangeOpac(id) {
	//alert("opac");
	if(ie5) divs[id].filters.alpha.opacity = nOver * 200;
	if(ns6) divs[id].style.MozOpacity = nOver;
}

function ChangeBack(id) {
	//alert("back");
		if(ie5) divs[id].filters.alpha.opacity = nStart * 100;
	if(ns6) divs[id].style.MozOpacity = nStart;
}

function ChangeOpacInit() {
    	if(document.getElementById){
        	divs = document.getElementsByTagName("div");
		for(var i=0; i<divs.length; i++) {
			//divs[i].style.visibility = "visible";
        		if(ie5) divs[i].style.filter="alpha(opacity="+ nStart * 100 +")";
			if(ns6) divs[i].style.MozOpacity = nStart;
		}
    	}
	
}



