// JavaScript Document
//PROTOTYPE
//show in status
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = "";
}//clear text
function scFormLanding(){
	
	
	if($F('email_email')=="" || $F('email_email')=="Email Address"){
	alert("Please Enter Your Email Address");
	}else if($F('email_name')=="First Name"){
	alert("Please Enter Your First Name");
	}else if($F('email_last')=="Last Name"){
	alert("Please Enter Your Last Name");
	}else{
		if($F('email_email')!=$F('email_email2') || $F('email_email2')==""){
		alert("Please Confirm Your Email Address");
		}else{
		
		formSender("http://www.stylecaster.com/register/pre_email", "form_pre", "right_form", "");
		
		}
	}
	
	
}


function getMePost(url, content, params) {	 
	var ajax = new Ajax.Updater(
	{success: content},
	url,
	{method: 'post', parameters: params});
}

var loader;
var status;
function formSend(url, formName, params, loader, status) {

var pars=$(formName).serialize();

var ajax = new Ajax.Request( 
	url,
	{method: 'post', 
	postBody: pars, 
	parameters: params,
	onLoading: function (){
	$(loader).style.display = 'block';
	}, 
	onComplete:function (originalRequest){
	var newData = originalRequest.responseText;
	$(loader).style.display = 'none';
	$(status).innerHTML = newData;
	
	}});

} 


//for to show in div
function formSender(url, formName, content, params) {


var pars=$(formName).serialize();
var ajax = new Ajax.Updater(
	{success: content},
	url,
	{method: 'post', postBody: pars, parameters: params});
	//Effect.SlideDown(content, { duration: 1.0 });
} 



  var effect_1 = null;
  var flags=false;
  function effect(){
  
  //Effect.SlideUp('d1',{duration:1.0});
  	if(flags==false){
	Effect.SlideDown('d1',{duration:1.0}); 
	flags=true;
	}else{
	Effect.SlideUp('d1',{duration:1.0});
	flags=false;
	}
}
  
  var flag = new Array();	
  function getEffect(con){
	 
	if(flag[con]==undefined){flag[con]=false;}
	if(flag[con]==false){
	Effect.SlideDown(con,{duration:1.0});
	flag[con]=true;
	}else{
	Effect.SlideUp(con,{duration:1.0});
	flag[con]=false;
	}
  }
  
  function pause(numberMillis){
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true){
	now = new Date();
	if (now.getTime() > exitTime)
	return;
	}
 } 
  
  var attBar;
  function statusOpen(con, attBar2){
	
	
	if(attBar==undefined){attBar=true;}
	
	
	if(attBar==true){
	//getMePost("http://www.google.com", 'alert_bottom_in', '');
	$('status_arrow').src = "http://www.stylecaster.com/images/frontend/icons/status_down.gif"; 
	Effect.SlideDown(con,{duration:0.2});
	attBar=false;
	
	//pause(400);
	setTimeout("closePop()",3000);
	}
	
	if(attBar2==false){
	closePop();
	}
	
	
  }  
  
  function closePop(){
  	$('status_arrow').src = "http://www.stylecaster.com/images/frontend/icons/status_up.gif"; 
  	Effect.SlideUp('alert-bottom',{duration:0.2});
 	attBar=true;  
	  
	  
	  
  }
  
  
 // var flag = new Array();	
  function topHeader(con){
	//alert(con);
	if(flag[con]==undefined){flag[con]=false;}
	if(flag[con]==false){
	Effect.SlideDown(con,{duration:1.0});
	getMe('http://www.stylecaster.com/member/top_location', 'scLocation', '');
	
	flag[con]=true;
	}else{
	Effect.SlideUp(con,{duration:1.0});
	flag[con]=false;
	}
  }
  
  
  //var flag = new Array();	
  function getLeftNav(con, showmore, tri){
	if(flag[con]==undefined){flag[con]=false;}
	if(flag[con]==false){
	Effect.SlideDown(con,{duration:0});
	$(showmore).hide();
	
	$(tri).className = 'nv_TO';
	flag[con]=true;
	}else{
	Effect.SlideUp(con,{duration:0});
	$(showmore).show();
	$(tri).className = 'nv_TC';
	flag[con]=false;
	}
  }  
  
  
  function getMe(url, content, params) {	 
	//var url = 'test.php';
	//var params = 'zip=' + $F('zip');
	var ajax = new Ajax.Updater(
	{success: content},
	url,
	{method: 'get', parameters: params});
	//{method: 'get'});
	//Effect.SlideDown(content, { duration: 3.0 });
	//Effect.Fader(content);
	//Effect.FadeIn(content);
	
}



function showHide(id, action){

		
		var d = $("over"+id);
		var d2 = $("overOn"+id);
		var ajaxLoading=1;
		
		if(action=='hide'){
		d.hide();d2.hide();
		ajaxLoading=1;
		}else{
			if(ajaxLoading!=0){
			d.show();d2.show();
			ajaxLoading=0;
			}
		}
		//alert(d.innerHTML);
		//d.addClassName('active');
	}


function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function setWrapHeight() { 
	if (document.getElementById) { 
	var groundheight = getWindowHeight(); 
		//alert(groundheight);
		if (groundheight > 0 && groundheight > 865) { 
			var groundElement = document.getElementById('wrap'); 
			groundElement.style.height = groundheight + 'px';         
		} else{
			var groundElement = document.getElementById('wrap'); 
			groundElement.style.height = '865 px';    
		}       
	}         
}


//to center the window 
dom = (document.getElementById) ? true : false;
ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
ns4 = (document.layers && !dom) ? true : false;
ie4 = (document.all && !dom) ? true : false;
nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

//

//detect browser

isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

//

//to open center popup
function openWin(name,wid,hei,sbar,title){

	xx=screen.availWidth/2-wid/2;
	yy=screen.availHeight/2-hei/2;
	str="left=" + Math.round(xx) + ",top=" + Math.round(yy);
	window.open(name,title,'width='+wid+',height='+hei+',toolbar=no,scrollbars='+sbar+',resizable='+sbar+','+str);

}

function show(object) {
    if (document.layers && document.layers[object])
        document.layers[object].visibility = 'visible';
    else if (document.all) {
        document.all[object].style.visibility = 'visible';
        document.all[object].style.zIndex = 100;
    }
}
function hide(object) {
    if (document.layers && document.layers[object])
        document.layers[object].visibility = 'hidden';
    else if (document.all)
        document.all[object].style.visibility = 'hidden';
}
function checkrequired(which) {
var pass=true;
   if (document.images) {
      

      for (i=0;i<which.length;i++) {
      var tempobj=which.elements[i];
         if (tempobj.name.substring(0,8)=="required") {
		      //---added
			  if (tempobj.defaultValue==tempobj.value)
              tempobj.value = ""
			//-----------
			  
			  
              if (((tempobj.type=="text"||tempobj.type=="textarea")&&
              tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
              tempobj.selectedIndex==0)) {
              pass=false;
              break;
              }
        }
      }
  }
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("Error: Please Fill the requirement");
return false;
}
else
return true;
}//end of function