// JavaScript Document

function vendortype()
{
	if(document.getElementById('vendor_type').value == 'others')
		{
			document.getElementById('other_vendors').style.display = 'inline';
		}
	else
		{
			dupload_imageocument.getElementById('other_vendors').style.display = 'none';
		}
}

function otherstate()
{
	if(document.getElementById('state').value == 'others')
		{
			document.getElementById('other_state').style.display = 'inline';
		}
	else
		{
			document.getElementById('other_state').style.display = 'none';
		}
}

function otherstate2(dd)
{
	if(document.getElementById('state2').value == 'others')
		{
			document.getElementById('other_state2').style.display = 'inline';
		}
	else
		{
			document.getElementById('other_state2').style.display = 'none';
		}
}

function go_step1() {
	window.location.href = 'signup_step1.html';
}
function go_step2() {
	window.location.href = 'signup_step2.html';
}

function go_step3() {
	window.location.href = 'signup_step3.html';
}

function go_step3() {
	window.location.href = 'signup_step3.html';
}

function goto_w5() {
	document.getElementById('w5').style.display = 'block';
	document.getElementById('w4').style.display = 'none';
	document.getElementById('w2').style.display = 'none';
	document.getElementById('w1').style.display = 'none';
	document.getElementById('w3').style.display = 'none';
	document.getElementById('w6').style.display = 'none';
}

function goto_w6() {
	document.getElementById('w6').style.display = 'block';
	document.getElementById('w4').style.display = 'none';
	document.getElementById('w2').style.display = 'none';
	document.getElementById('w1').style.display = 'none';
	document.getElementById('w3').style.display = 'none';
	document.getElementById('w5').style.display = 'none';
}

function goto_signup() {
	window.location.href = 'become_a_member.html';
}
function go_subrequest() {
	window.location.href = 'subscription_request.html';
}

function goto_wedding_image() {
	window.location.href = 'wedding_images.html';
}

var old = 'one';
var dold = 'done'
function show(a) {
	var container = ('d' + a);
	document.getElementById(old).style.display = 'none';
	document.getElementById(dold).className = 'tab_deselect';
	document.getElementById(a).style.display = 'block';
	document.getElementById(container).className = 'tab_select';
	old = a;
	dold = container;
}

function other_vendor() {

		if (document.getElementById('other_vendor').checked) {
			document.getElementById('othervendor').style.display = 'inline';
		}
		else {
			document.getElementById('othervendor').style.display = 'none';
		}

}


function reception(chk) {

		if (chk.checked) {
			document.getElementById('reception').style.display = 'inline';
		}
		else {
			document.getElementById('reception').style.display = 'none';
		}

}


function pop_slideshow(){
	window.open("popup_slideshow.html",null,",height=350,width=670,status=yes,scrollbars=1,toolbar=no,menubar=no,location=no");
}

function pop_ins_board(){
	window.open("popup_ins_board.html",null,",height=400,width=670,status=yes,scrollbars=1,toolbar=no,menubar=no,location=no");
}


function pop_edit_image_info_old(){
	window.open("popup_image_info.html",null,",height=400,width=670,status=yes,scrollbars=1,toolbar=no,menubar=no,location=no");
}

function upload_image(url){
	window.open(url,null,",height=550,width=800,status=yes,scrollbars=1,toolbar=no,menubar=no,location=no");
}

function upload_image_big(url){
	window.open(url,null,",height=550,width=950,status=yes,scrollbars=1,toolbar=no,menubar=no,location=no");
}

function save_image() {
	document.getElementById('saveimage').style.display = 'inline';
	document.getElementById('downloadimage').style.display = 'none';
	document.getElementById('sendimage').style.display = 'none';
	document.getElementById('slide_board').style.display = 'none';
	document.getElementById('ins_board').style.display = 'none';
}

function hide_keyword() {
		document.getElementById('saveimage').style.display = 'none';
}

function download_image() {
	document.getElementById('downloadimage').style.display = 'inline';
	document.getElementById('saveimage').style.display = 'none';
	document.getElementById('sendimage').style.display = 'none';
	document.getElementById('slide_board').style.display = 'none';
	document.getElementById('ins_board').style.display = 'none';
	//document.getElementById('play').style.zIndex = '-1';
	//document.getElementById('play').style.position = 'relative';
}

function hide_download() {
		document.getElementById('downloadimage').style.display = 'none';
		//document.getElementById('play').style.zIndex = '+1';
}

function send_image() {
	document.getElementById('sendimage').style.display = 'inline';
	document.getElementById('downloadimage').style.display = 'none';
	document.getElementById('saveimage').style.display = 'none';
	document.getElementById('slide_board').style.display = 'none';
	document.getElementById('ins_board').style.display = 'none';
	//document.getElementById('play').style.zIndex = '-1';
	//document.getElementById('play').style.position = 'relative';
}


function hide_send_image(){
	document.getElementById('sendimage').style.display = 'none';
	//document.getElementById('play').style.zIndex = '+1';
}

function show_slide() {
	document.getElementById('slide_board').style.display = 'block';
	document.getElementById('downloadimage').style.display = 'none';
	document.getElementById('saveimage').style.display = 'none';
	document.getElementById('ins_board').style.display = 'none';
	document.getElementById('sendimage').style.display = 'none';
}

function hide_slide(){
	document.getElementById('slide_board').style.display = 'none';
}



function show_ins() {
	document.getElementById('ins_board').style.display = 'inline';
	document.getElementById('downloadimage').style.display = 'none';
	document.getElementById('saveimage').style.display = 'none';
	document.getElementById('sendimage').style.display = 'none';
	document.getElementById('slide_board').style.display = 'none';
}

function hide_ins(){
	document.getElementById('ins_board').style.display = 'none';
}


function select_template()
{
	if(document.getElementById('select_template').value == 'template1')
		{
			document.getElementById('template1').style.display = 'inline';
			document.getElementById('template2').style.display = 'none';
			document.getElementById('template3').style.display = 'none';
		}
	else if(document.getElementById('select_template').value == 'template2')
		{
			document.getElementById('template2').style.display = 'inline';
			document.getElementById('template3').style.display = 'none';
			document.getElementById('template1').style.display = 'none';
		}
	else if(document.getElementById('select_template').value == 'template3')
		{
			document.getElementById('template3').style.display = 'inline';
			document.getElementById('template1').style.display = 'none';
			document.getElementById('template2').style.display = 'none';
		}
}

function goto_lightboard() {
		window.location.href = 'lightboard.html';
}


function add_member(url) {

		window.open(url,null,",height=400,width=670,status=yes,scrollbars=1,toolbar=no,menubar=no,location=no");


}

function close_add_member() {
		document.getElementById('addmember').style.display = 'none';
}


function refer_fav() {
		document.getElementById('refer_fav').style.display = 'block';
}

function close_refer_fav() {
		document.getElementById('refer_fav').style.display = 'none';
}

function usertype()
{
	if(document.getElementById('show_usertype').value == 'editorial')
		{
			document.getElementById('editorial').style.display = 'inline';
			document.getElementById('corporate').style.display = 'none';
		}
	else if(document.getElementById('show_usertype').value == 'corporate')
		{
			document.getElementById('corporate').style.display = 'inline';
			document.getElementById('editorial').style.display = 'none';
		}
	else {
			document.getElementById('corporate').style.display = 'none';
			document.getElementById('editorial').style.display = 'none';
	}
}

function select_state(dd)
{
	if(dd == 0)
		{
			document.getElementById('otherstate').style.display = 'inline';
		}
	else
		{
			document.getElementById('otherstate').style.display = 'none';
		}
		if( document.getElementById('hdn_user_state_id') )
			document.getElementById('hdn_user_state_id').value = dd;
}
function select_state_sub(dd)
{
	if(dd == 0)
		{
			document.getElementById('otherstate_sub').style.display = 'inline';
		}
	else
		{
			document.getElementById('otherstate_sub').style.display = 'none';
		}
		if( document.getElementById('hdn_sub_state_id') ){
			document.getElementById('hdn_sub_state_id').value = dd;
			//alert(dd);
		}
}

function goto_login() {
		window.location.href = 'login.html';
}

function show_editorial() {
		document.getElementById('div_editotrial').style.display = 'inline';
}

function hide_editorial() {
		document.getElementById('div_editotrial').style.display = 'none';
}

function show_cvv() {
		document.getElementById('div_cvv').style.display = 'inline';

}

function hide_cvv() {
		document.getElementById('div_cvv').style.display = 'none';
}

function show_what(div) {
		document.getElementById(div).style.display = 'inline';
}

function hide_what(div) {
		document.getElementById(div).style.display = 'none';
}

function show_what2() {
		document.getElementById('div_what2').style.display = 'inline';
}

function hide_what2() {
		document.getElementById('div_what2').style.display = 'none';
}

function hide_send_msg() {
		document.getElementById('send_msg').style.display = 'none';
}



checked=false;

function checkedAll (check) {

	var aa= document.getElementById('check');
	 if (checked == false)
          {
           checked = true;
          }
        else
          {
          checked = false;
          }
	for (var i =0; i < aa.elements.length; i++)
	{	
	 aa.elements[i].checked = checked;	 		 
	 if(document.getElementById(aa.elements[i].id + "_hdn")) {	 	 		
	 	if(document.getElementById(aa.elements[i].id + "_hdn").value != 0 ) {
	 		aa.elements[i].checked = false;	 		
	 	}
	 }
	 }
	
}


checked2=false;

function checkedAll2 (check2) {

	var bb= document.getElementById('check2');

	 if (checked2 == false)
          {
           checked2 = true;
          }
        else
          {
          checked2= false;
          }
	for (var z =0; z < bb.elements.length; z++)
	{
	 bb.elements[z].checked = checked2;
	}
}

function showStatus(sS){
	if (document.getElementById(sS).checked == true){
		document.getElementById(sS+'Txt').style.display = 'block';
	}
	else {
		document.getElementById(sS+'Txt').style.display = 'none';
	}
}

function showVideo(){
	document.getElementById('video').style.display = 'block';
	videotimer();
}


var videosecs						//	For Storing the Seconds
var videotimerID = null;				//	For Storing timer id
var videotimerRunning = false;		//	initialy timer running will be in NULL
var videodelay = 1000;				//	For Storing Delay (SPEED)

function videotimer(){				//	For TIMER function
	videosecs = 0;
	videostopTheClock();
	videostartTheTimer();
}
function videostopTheClock()			//	For Stop the Timer function
{
    if(videotimerRunning) {
        clearTimeout(videotimerID)
	    videotimerRunning = false;
	}
}
function videostartTheTimer()		//	For Start the Timer function
{
//	self.status = videosecs
    videosecs = videosecs + 1
    videotimerRunning = true			//	Changing timer running is TRUE
    videotimerID = self.setTimeout("videostartTheTimer()", videodelay)		//	For starting timer and speed of the timer

	if (videosecs > 10){
		videostopTheClock();						//	For Stop the Timer
		document.getElementById('video').style.display = 'none';
	}
}


function showCustomTag() {
	document.getElementById('customTag').style.display = 'block';
}
function hideCustomTag() {
	document.getElementById('customTag').style.display = 'none';
}


function show_count() {
	document.getElementById('div_count').style.display = 'block';
}

function hide_count() {
	document.getElementById('div_count').style.display = 'none';
}


var oldTemplate = 'templateWrap1';
function showTemplate(sT){
	document.getElementById(oldTemplate).style.display = 'none';
	document.getElementById('templateWrap'+sT).style.display = 'block';

	oldTemplate = 'templateWrap'+sT;
}

function show_details(id) {
		close_all_details_div();
		document.getElementById('div_details'+id).style.display = 'block';
}

function hide_details(id) {
		close_all_details_div();
		document.getElementById('div_details'+id).style.display = 'none';
}

function close_all_details_div()
{
	var row_count = document.getElementById('rows_count').value;
	for(i=1;i<=row_count;i++)
	{
		if(document.getElementById('div_details'+i))
			document.getElementById('div_details'+i).style.display = 'none';
	}
}



var count2 = '-1';
	function show_hide_criteria() {

		if (count2 == '-1'){
			document.getElementById('criteria').style.display = 'inline';
			document.getElementById('search_left').className ='search_left_w';
			document.getElementById('search_middle_w').className ='search_middle_w';
			document.getElementById('search_right').className ='search_right_w';
			document.getElementById('search_bottom').style.display ='inline';
		}
		else {
			document.getElementById('criteria').style.display = 'none';
			document.getElementById('search_left').className ='search_left';
			document.getElementById('search_middle_w').className ='search_bg';
			document.getElementById('search_right').className ='search_right';
			document.getElementById('search_bottom').style.display ='none';

		}
		count2 = -(count2 - 1);
	}


var count3 = '-1';
	function show_hide_mug() {

		if (count3 == '-1'){
			document.getElementById('mug').style.display = 'inline';

		}
		else {
			document.getElementById('mug').style.display = 'none';

		}
		count3 = -(count3 - 1);
	}

var count4 = '-1';
	function show_hide_organize() {

		if (count4 == '-1'){
			document.getElementById('organize').style.display = 'inline';

		}
		else {
			document.getElementById('organize').style.display = 'none';

		}
		count4 = -(count4 - 1);
	}


function show_ins_board() {
	document.getElementById('ins_wizard').style.display = 'inline';
	document.getElementById('step2_ins').style.display = 'none';
}

function hide_ins_board() {
	document.getElementById('ins_wizard').style.display = 'none';
}


function step2_ins() {
	document.getElementById('step2_ins').style.display = 'inline';
	document.getElementById('step1_ins').style.display = 'none';
}


function goto_step1_ins() {
	document.getElementById('step2_ins').style.display = 'none';
	document.getElementById('step1_ins').style.display = 'inline';
}

function show_signupwizard() {
	document.getElementById('show_signupwizard').style.display = 'inline';
	document.getElementById('step2_signup').style.display = 'none';
}

function hide_signupwizard() {
		document.getElementById('show_signupwizard').style.display = 'none';
}

function show_icons() {
	document.getElementById('icons').style.display = 'block';
}

function hide_icons() {
		document.getElementById('icons').style.display = 'none';
}



function step1_signup() {
	document.getElementById('step1_signup').style.display = 'block';
	document.getElementById('step2_signup').style.display = 'none';
//	document.getElementById('step3_signup').style.display = 'none';
	document.getElementById('step4_signup').style.display = 'none';
	document.getElementById('step5_signup').style.display = 'none';
	document.getElementById('step3_signup_verify').style.display = 'none';
	document.getElementById('step6_signup').style.display = 'none';
	change_page_title(1);
}

function step2_signup() {
	document.getElementById('step2_signup').style.display = 'block';
	document.getElementById('step1_signup').style.display = 'none';
//	document.getElementById('step3_signup').style.display = 'none';
	document.getElementById('step4_signup').style.display = 'none';
	document.getElementById('step5_signup').style.display = 'none';
	document.getElementById('step3_signup_verify').style.display = 'none';
	document.getElementById('step6_signup').style.display = 'none';
	change_page_title(2);
}

function step3_signup() {
	//defined on index.ctp:
	//showStep3Divs();
	document.getElementById('step3_signup').style.display = 'block';
	document.getElementById('step1_signup').style.display = 'none';
	document.getElementById('step2_signup').style.display = 'none';
	document.getElementById('step4_signup').style.display = 'none';
	document.getElementById('step5_signup').style.display = 'none';
	document.getElementById('step3_signup_verify').style.display = 'none';
	document.getElementById('step6_signup').style.display = 'none';
	change_page_title(2);
}

function step3_signup_verify() {
	document.getElementById('step3_signup_verify').style.display = 'block';
	document.getElementById('step1_signup').style.display = 'none';
	document.getElementById('step2_signup').style.display = 'none';
	document.getElementById('step4_signup').style.display = 'none';
	document.getElementById('step5_signup').style.display = 'none';
//	document.getElementById('step3_signup').style.display = 'none';
	document.getElementById('step6_signup').style.display = 'none';
	change_page_title(2);
}


function step4_signup() {
	document.getElementById('step4_signup').style.display = 'block';
	document.getElementById('step1_signup').style.display = 'none';
	document.getElementById('step2_signup').style.display = 'none';
//	document.getElementById('step3_signup').style.display = 'none';
	document.getElementById('step5_signup').style.display = 'none';
	document.getElementById('step3_signup_verify').style.display = 'none';
	document.getElementById('step6_signup').style.display = 'none';
	change_page_title(3);
}

function step5_signup() {
	document.getElementById('step5_signup').style.display = 'block';
	document.getElementById('step1_signup').style.display = 'none';
	document.getElementById('step2_signup').style.display = 'none';
//	document.getElementById('step3_signup').style.display = 'none';
	document.getElementById('step4_signup').style.display = 'none';
	document.getElementById('step3_signup_verify').style.display = 'none';
	document.getElementById('step6_signup').style.display = 'none';
	change_page_title(4);
}

function step6_signup() {
	document.getElementById('step6_signup').style.display = 'block';
	document.getElementById('step5_signup').style.display = 'none';
	document.getElementById('step1_signup').style.display = 'none';
	document.getElementById('step2_signup').style.display = 'none';
//	document.getElementById('step3_signup').style.display = 'none';
	document.getElementById('step4_signup').style.display = 'none';
	document.getElementById('step3_signup_verify').style.display = 'none';
	change_page_title(5);
}

function show_others() {
		if (document.getElementById('other_suggest').checked) {
			document.getElementById('other_suggestion').style.display = 'block';
		}
		else {
			document.getElementById('other_suggestion').style.display = 'none';
		}
}

function show_refer_mail() {
		document.getElementById('preview').style.display = 'inline';
}

function not_cancel_pgrapher() {
	document.getElementById('pgrapher_no').style.display = 'block';
	document.getElementById('pgrapher_yes').style.display = 'none';
}

function cancel_pgrapher() {
	document.getElementById('pgrapher_yes').style.display = 'block';
	document.getElementById('pgrapher_no').style.display = 'none';
}

function not_cancel_vendor() {
	document.getElementById('vendor_no').style.display = 'block';
	document.getElementById('vendor_yes').style.display = 'none';
}

function cancel_vendor() {
	document.getElementById('vendor_yes').style.display = 'block';
	document.getElementById('vendor_no').style.display = 'none';
}

function not_cancel_corporate() {
	document.getElementById('corporate_no').style.display = 'block';
	document.getElementById('corporate_yes').style.display = 'none';
}

function cancel_corporate() {
	document.getElementById('corporate_yes').style.display = 'block';
	document.getElementById('corporate_no').style.display = 'none';
}
/**********************/
function trim(string) {
		return string.replace(/^\s+|\s+$/g,"");
}

function checkEmail(string) {
	filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i  ;
	if (filter.test(string))
		return 1;
	else
		return 0;
}

function checkValidURL(field,excval,errstmt){
	var httpregex=/^([a-zA-Z]+:\/\/)/
	var urlregex=/^\w+.[.\w]*\w$/;
	var value=field.value;

	var match=value.match(httpregex); // has a protocol indicator
	  if (match){
	        match=field.value.substr(match[1].length,value.length)
	        match=match.match(urlregex);
	  }else{
	        var match=value.match(urlregex);
	  }
	  if(!match){
	        if (errstmt) alert(errstmt);
	        if (excval) eval(excval);
	        return false;
	  }else return true;
}

function gev( ID ){
	if(document.getElementById( ID ))
		return trim(document.getElementById( ID ).value);
}
function geo( ID ){
	return document.getElementById( ID );
}

function display_criteria(url){
	window.open(url,null,",height=500,width=900,status=yes,scrollbars=1,toolbar=no,menubar=no,location=no");
}

function criteria_field(id_value) {

	var spl_val = id_value.split('@@@@');
		if (spl_val[1] == 0)
		{
			document.getElementById('site_average').style.display = 'inline';
		}
	else
		{
			document.getElementById('site_average').style.display = 'none';
		}

}

function ValidateDelete()
{
	var count = document.getElementById('rows_count').value;

	var j=0;
	for(i=1;i<=count;i++)
	{
		if(document.getElementById('chk'+i).checked == true)
			j++;
	}

	if(j<=0)
	{
		alert('Please select at least one row to delete');
		return false;
	}
	else
	{

		if(confirm('Are you sure to Delete ?'))
		{
				document.check.submit();
		}
		else
		{
			return false;
		}
	}
}

//numbers only
function numbersonly(e, ftype){
	var unicode=e.charCode? e.charCode : e.keyCode;
	//alert(unicode);
 //  	if(unicode ==  48) return false;
	//if (unicode!=8 || unicode!=36 || unicode!=37 || unicode!=38 || unicode!=39 || unicode!=40) { //if the key isn't the backspace key (which we should allow)
	/*if(unicode ==  118 ||unicode ==  37 || unicode ==  38 || unicode ==  39 || unicode ==  40 || unicode ==  9 || unicode ==  8 || unicode ==  46 ) return true;

	if (unicode!=8) { //if the key isn't the backspace key (which we should allow)
	//	if(unicode == 9 || uncode ==10 && (unicode<36||unicode>57) )
	if (unicode<46||unicode>57 )
	// alert("Please Enter number");
	 //if not a number
	return false; //disable key press
	}
	else
	{
		return true;
	}*/	
	if( unicode ==  8 || unicode ==  9 || unicode ==  39 || unicode ==  37 || unicode ==  46 ) return true;
	if (unicode!=8 && unicode !=13) 
	{ 
		//	if(unicode == 9 || uncode ==10 && (unicode<36||unicode>57) )
		if (unicode < 48 || unicode > 57 )
		{
			/*if (ftype)
				alert("Please enter " + ftype + " with numerical digits only");
			else
				alert("Please enter numerical digits only");*/
		 	//if not a number
			return false; //disable key press
		}
	}
	else
	{
		return true;
	}
}
function numbersonly_new(e, ftype){
	var unicode=e.charCode? e.charCode : e.keyCode;
	//alert(unicode);
 //  	if(unicode ==  48) return false;
	//if (unicode!=8 || unicode!=36 || unicode!=37 || unicode!=38 || unicode!=39 || unicode!=40) { //if the key isn't the backspace key (which we should allow)
	/*if(unicode ==  118 ||unicode ==  37 || unicode ==  38 || unicode ==  39 || unicode ==  40 || unicode ==  9 || unicode ==  8 || unicode ==  46 ) return true;

	if (unicode!=8) { //if the key isn't the backspace key (which we should allow)
	//	if(unicode == 9 || uncode ==10 && (unicode<36||unicode>57) )
	if (unicode<46||unicode>57 )
	// alert("Please Enter number");
	 //if not a number
	return false; //disable key press
	}
	else
	{
		return true;
	}*/	
	if( unicode ==  8 || unicode ==  9 || unicode ==  39 || unicode ==  37 || unicode ==  46 ) return true;
	if (unicode!=8 && unicode !=13) 
	{ 
		//	if(unicode == 9 || uncode ==10 && (unicode<36||unicode>57) )
		if (unicode < 48 || unicode > 57 )
		{
			/*if (ftype)
				alert("Please enter " + ftype + " with numerical digits only");
			else
				alert("Please enter numerical digits only");*/
		 	//if not a number
			return false; //disable key press
		}
	}
	else
	{
		return true;
	}
}

function check_url( url ) {
	 var ret = 0;
	 if ( (/http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z0-9]{3}/).test( url )){
	     ret = 1;
	 }
	 if ( (/https:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z0-9]{3}/).test( url )){
	     ret = 1;
	 }
	 return ret;
}




function validChars(str)
{
if (/^[a-z\s\d]*$/i.test(str))
return true;
else
return false;
}
/**
This will clear the message divs generated by Cake:
*/
function clearCakeMessageDiv( divId ){
	message_class = 'error-message';
	var container;
	if( trim(divId) == '' ){
		container = document.getElementsByTagName("div");
	}else{
		container = document.getElementById(divId).getElementsByTagName('div');
	}
	if( container.length > 0 ){
		for( var i = 0; i < container.length; i++ ){
			if( container[i].className == message_class ){
				container[i].innerHTML = "";
				container[i].className = "";
			}
		}
	}
}

function toggleElem( elem,value ){
	if( document.getElementById(elem) )
		document.getElementById(elem).style.display = (value==0)?'none':'inline';
}

function showError( elem, message ){
	if( document.getElementById('span_'+elem) )
		document.getElementById('span_'+elem).style.display = 'inline';
	if( document.getElementById('error_'+elem) ){
		document.getElementById('error_'+elem).style.display = 'inline';
		document.getElementById('error_'+elem).innerHTML = message;
	}

}
function clearError(elem){
	if( document.getElementById('span_'+elem) )
		document.getElementById('span_'+elem).style.display = 'none';
	if( document.getElementById('error_'+elem) ){
		document.getElementById('error_'+elem).innerHTML = '';
		document.getElementById('error_'+elem).style.display = 'none';

	}
}

function ValidateMerge()
{
	var count = document.getElementById('rows_count').value;

	var j=0;
	for(i=1;i<=count;i++)
	{
		if(document.getElementById('chk'+i).checked == true)
			j++;
	}

	if(j!=2)
	{
		alert('Please select exactly 2 rows to merge');
		return false;
	}
	else
	{

		if(confirm('Are you sure to Merge the selected weddings ?'))
		{
				document.check.submit();
		}
		else
		{
			return false;
		}
	}
}

function goToUrl( url ){
	window.location.href=url;
}
function nl2br (str) {
	var breakTag = '<br />';
    return (str + '').replace(/([^>]?)\n/g, '$1'+ breakTag +'\n');
}
checked=false;

function checkall_creations (frm_id) {

	var aa= document.getElementById(frm_id);
	 if (checked == false)
          {
           checked = true;
          }
        else
          {
          checked = false;
          }
	for (var i =0; i < aa.elements.length; i++)
	{
	 aa.elements[i].checked = checked;
	}
}
/**
*arguements:
divId : id of the message div if you want to show the message in a div
type: alert/div
*/
function checkPopupBlocker(divId, type){
	var w = screen.width;
	var h =  screen.height;
	var win = window.open('','','width=1,height=1,innerWidth=1,innerHeight=1,outerWidth=1,outerHeight=1,left='+w/2+',top='+h/2+',scrollbars=no');

	var div = document.getElementById(divId);
	var message = "It is detected that Browser Popup Blocker is active. Please enable it to see the Popup windows";
	var ret = true;
	if( win ){
		ret = true;
		win.close();
	}else{
		ret = false;
		if( type == 'alert' ){
			alert( message );
		}
		else if( div ){
			div.innerHTML = message;
		}
	}
	return ret;
}

/* Added for editoral submition */
function show_estep1() {
		document.getElementById('editorial_left1').style.display = 'block';
		document.getElementById('editorial_left2').style.display = 'none';
		document.getElementById('editorial_left3').style.display = 'none';
		document.getElementById('editorial_left4').style.display = 'none';
		document.getElementById('editorial_right1').style.display = 'block';
		document.getElementById('editorial_right2').style.display = 'none';
		document.getElementById('editorial_right3').style.display = 'none';
		document.getElementById('editorial_right4').style.display = 'none';
}

function show_estep2() {
		document.getElementById('editorial_left1').style.display = 'none';
		document.getElementById('editorial_left2').style.display = 'block';
		document.getElementById('editorial_left3').style.display = 'none';
		document.getElementById('editorial_left4').style.display = 'none';
		document.getElementById('editorial_right1').style.display = 'none';
		document.getElementById('editorial_right2').style.display = 'block';
		document.getElementById('editorial_right3').style.display = 'none';
		document.getElementById('editorial_right4').style.display = 'none';
}

function show_estep3() {
		document.getElementById('editorial_left1').style.display = 'none';
		document.getElementById('editorial_left2').style.display = 'none';
		document.getElementById('editorial_left3').style.display = 'block';
		document.getElementById('editorial_left4').style.display = 'none';
		document.getElementById('editorial_right1').style.display = 'none';
		document.getElementById('editorial_right2').style.display = 'none';
		document.getElementById('editorial_right3').style.display = 'block';
		document.getElementById('editorial_right4').style.display = 'none';

}

function show_estep4() {
		document.getElementById('editorial_left1').style.display = 'none';
		document.getElementById('editorial_left2').style.display = 'none';
		document.getElementById('editorial_left3').style.display = 'none';
		document.getElementById('editorial_left4').style.display = 'block';
		document.getElementById('editorial_right1').style.display = 'none';
		document.getElementById('editorial_right2').style.display = 'none';
		document.getElementById('editorial_right3').style.display = 'none';
		document.getElementById('editorial_right4').style.display = 'block';

}
function choose_ex_nonex()
{
	
	if(document.getElementById('exnonex').value == '1')
		{
			document.getElementById('ex').style.display = 'block';
			document.getElementById('nonex').style.display = 'none';
		}
	else if(document.getElementById('exnonex').value == '0')
		{
			document.getElementById('ex').style.display = 'none';
			document.getElementById('nonex').style.display = 'block';
		}
	else
		{
			document.getElementById('nonex').style.display = 'none';
			document.getElementById('ex').style.display = 'none';
		}
}


function choose_ex_nonex_step3()

{
	if(document.getElementById('exnonex').value == 'exclusive')
		{
			document.getElementById('ex').style.display = 'block';
			document.getElementById('nonex').style.display = 'none';
		}
	else if(document.getElementById('exnonex').value == 'nonexclusive')
		{
			document.getElementById('ex').style.display = 'none';
			document.getElementById('nonex').style.display = 'block';
		}
	else 
		{
			document.getElementById('nonex').style.display = 'none';
			document.getElementById('ex').style.display = 'none';
		}
}

function show_details(a){
		if ( (document.getElementById('details_text_'+a).style.display) == 'none') {
			document.getElementById('details_text_'+a).style.display = 'block';
			document.getElementById('details_'+a).innerHTML = 'hide details';
		}
		else {
			document.getElementById('details_text_'+a).style.display = 'none';
			document.getElementById('details_'+a).innerHTML = 'view details';
		}

}

function show_details_constellation(id) {
		close_all_details_div();
		document.getElementById('div_details'+id).style.display = 'block';
}

function change_options(obj,label){
	var doc = 'Wedding'+label+'Label';
	
	//alert(doc);
	
	if(obj.selectedIndex == 1){
	 document.getElementById(doc).selectedIndex =1;
	 //document.getElementById('WeddingSecondLabel').readonly =1;
	}	 else {
		document.getElementById(doc).selectedIndex =0;
		//document.getElementById('WeddingSecondLabel').selectedIndex =1;
	}
	
}

function chkLength(ele){
		if(ele.value.length>1500){
			alert("You can't exceed more than 1500 characters.");
			ele.value=ele.value.substring(0,1500);
		}
	}
	
function compare_dates(fromDate,toDate) {
	
//alert(fromDate); //04/08/2011

   var objFromDate = fromDate;
   
   var objToDate = toDate;
   
   var fromname = 'From date';
   
   var toname = 'To date';
   
   	   var FromDate = new Date(objFromDate);
       var ToDate = new Date(objToDate);
       var CurDate = new Date();
       if(FromDate > ToDate)
       {
          // alert(fromname + " should be less than or equal to " + toname);
           
           showError( 'from_date', fromname + " should be less than or equal to " + toname);
           return 1; 
       }
       else if(FromDate > CurDate)
       {
          // alert("From date should be less than current date");
            showError( 'from_date', "From date should be less than current date");
           return 1; 
       }
       else if(ToDate > CurDate)
       {
           //alert("To date should be less than current date");
           showError( 'to_date', "To date should be less than or equal to current date" );
           return 1;
       }
return 0;

}

function showpopup(ele, what) {
	document.getElementById(ele).style.display = what;
}

