var site = "http://v3.blastro.com/streetfire/";

function setHidden(whichID){ 
	var elementID = document.getElementById(whichID); 
	elementID.style.display = 'none'; 
}

//sets the element to visible and changed it's toggle image 
function setVisible(whichID){ 
	var elementID = document.getElementById(whichID); 
	elementID.style.display = ''; 
} 
	
//toggles visibility based on current state 
function toggle(whichID){ 
	var elementID = document.getElementById(whichID); 
	if((elementID.style.display == '')||(elementID.style.display == 'block')){ 
		setHidden(whichID); 
	} else { 
		setVisible(whichID);
	}
}

function login() {
		var user = document.getElementById('username');
        var pass = document.getElementById('password');
        var varsString = 'username=' + user.value + '&password=' + pass.value + '&action=submit';
        ajax.requestFile = site+"login.php";
        ajax.method = 'POST';
        ajax.element = 'loginmessage';
		ajax.onCompletion = loggedIn;
        ajax.runAJAX(varsString);
}

function loggedIn() {
	if (ajax.response != null) {
		var success = "You have been successfully logged in.";
		if (ajax.response.toLowerCase() == success.toLowerCase()) {
			//hide ajaxloginform
        	var alog = document.getElementById('loginform');
			alog.style.display='none';
			var message = document.getElementById('loginmessage');
			message.style.display = '';
			message.innerHTML = ajax.response;
			var login = document.getElementById('login');
			login.style.display = 'none';
			var logout = document.getElementById('logout');
			logout.style.display = '';
			var myscions = document.getElementById('myscions');
			myscions.style.display = '';
			var myscionlink = myscions.getElementsByTagName('a');
			var user = document.getElementById('username');
			myscionlink[0].href = "gallery.html?myscions="+user.value;
			var fpwd = document.getElementById('forgotpw');
			fpwd.style.display = 'none';
			var currentLogin = document.getElementById('currentLogin');
			currentLogin.innerHTML = 'Logged in as <span class="loggedinas">'+user.value+'</span>';
			currentLogin.style.display = '';
			var signup = document.getElementById('signup');
			signup.style.display = 'none';
		}else{
			var message = document.getElementById('loginmessage');
			message.style.display = '';
			message.innerHTML = ajax.response;
		}
	}
}

function logout() {
        var varsString = 'action=logout';
        ajax.requestFile = site+"login.php";
        ajax.method = 'POST';
		ajax.element = 'logoutmessage';
		ajax.onCompletion = loggedOut;
        ajax.runAJAX(varsString);
}

function loggedOut() {
	if (ajax.response != null) {
		var success = "You have been logged out.";
		if (ajax.response.toLowerCase() == success.toLowerCase()) {
			//hide ajaxloginform
			var logout = document.getElementById('logout');
			logout.style.display = 'none';
			var login = document.getElementById('login');
			login.style.display = 'inline';
			var loginmessage = document.getElementById('loginmessage');
			loginmessage.style.display = 'none';	
			loginmessage.innerHTML = '';
			var myscions = document.getElementById('myscions');
			myscions.style.display = 'none';
			var signup = document.getElementById('signup');
			signup.style.display = '';
			var currentLogin = document.getElementById('currentLogin');
			currentLogin.innerHTML = '';
			currentLogin.style.display = 'none';
		}else{

		}
	}
}

function ftf() {
		var name = document.getElementById('yname');
		var email = document.getElementById('yemail');
		var to_name = document.getElementById('tname');
		var to_email = document.getElementById('temail');
		var carid = document.getElementById('carid');					
        var varsString = 'action=ftf&name='+name.value+'&email='+email.value+'&to_name='+to_name.value+'&to_email='+to_email.value+'&carid='+carid.value;

        ajax.requestFile = site+"emailAction.php";
        ajax.method = 'GET';
		ajax.element = 'ftfmessage';
		ajax.onCompletion = ftfSent;
        ajax.runAJAX(varsString);
}

function ftfSent() {
	if (ajax.response != null) {
		var success = "Your friend will get their message soon.";
		if (ajax.response.toLowerCase() == success.toLowerCase()) {
			//hide ajaxloginform
			alert("Your friend will get their message soon.");

		}else{

		}
	}
}

function copyclipboard(div_id) {
	
	 if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion >= "4.0"){
	  var embed = document.getElementById(div_id);
      embed.unselectable = "off";
      embed.focus();
   
      document.execCommand('SelectAll');
      document.execCommand('Copy');
   }else{
      alert("Sorry, this only works for Internet Exlorer")
   }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

 function launchFP(){
   		window.open(site+'forgotpassword.html','forgotpassword','width=352,height=80,left=500,top=100,toolbar=no,menubar=no,directories=no,location=no,scrollbars=no,status=no,resizable=no,fullscreen=no');
   }
   
   function launchDownload(fileid){
   		window.open(site+'download.php?fileid='+fileid,'Download','width=1,height=1,left=500,top=100,toolbar=no,menubar=no,directories=no,location=no,scrollbars=no,status=no,resizable=no,fullscreen=no');
   }
   
function write_sw(){
document.write('<object classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,0,0,0" 	ID="roof_builder" width="1140" height="446">');
document.write('<param name="src" value="'+site+'dcr/scion.dcr">');
document.write('<param name="swRemote" value="swSaveEnabled=\'true\' swVolume=\'true\' swRestart=\'true\' swPausePlay=\'true\' swFastForward=\'true\' swContextMenu=\'true\' ">');
document.write('<param name="sw1" value="starsandcircles:Stars and Circles:8,creatures:Creatures:52,skulls:Skull and Bones:7,spirals:Spirals:26,emblems:Emblems:26,fireflair:Fire Flair:25,razor:Razor:26,batwings:Bat Wings:17,arrows:Arrows:26,sideswipes:Sideswipes:25,flames:Flames:25,fun:Fun:25">');
document.write('<param name="sw2" value="'+site+'">');
document.write('<param name="sw3" value="bg_url-/img/backgrounds/;gallery_url-/gallery/;login_url-/php/login.php;lib_url-/library/;save_url-/php/save.php;flush_url-/php/flush.php;load_url-/php/load.png?id=;app_url-/roofgenerator/roof_builder.dcr;tofriend_url-/php/sendtofriend.php;picker_url-/my_designs/;register_url-/register/;forgetpasswd_url-/forgotpass">');
document.write('<param name="sw4" value="">   <!--load_id : specify saved design to load via load_url -->');
document.write('<param name="sw5" value="99999">  <!-- auth_id -->');
document.write('<param name="sw6" value="'+site+'/streetfire/dcr/scion.dcr">');
document.write('<param name="sw7" value="">  <!-- semicolon delimited keywords of saved design -->');
document.write('<param name="sw8" value="SOLID COLOR;ABSTRACT;BLUETUNNEL;MOUNTAINS;RUNWAY;WORKSHOP;FOREST;DISCO"> <!--background - loads via bg_url -->');
document.write('<param name="sw9" value="Super White:fcfcfc;Black Sand Pearl:000002;Blackberry Crush Metallic:3f2c28;Nautical Blue Metallic:30384f;Classic Silver Metallic:bdbfbc;Hypnotic Teal Mica:3b4747">');
document.write('<param name="bgColor" value="#000000"> ');
document.write('<embed src="'+site+'dcr/scion.dcr" bgColor="#000000" width="1140" height="446" swRemote="swSaveEnabled=\'true\' swVolume=\'true\' swRestart=\'true\' swPausePlay=\'true\' swFastForward=\'true\' swContextMenu=\'true\'"');
document.write('sw1="Stuff:5,starsandcircles:Stars and Circles:8,creatures:Creatures:52,skulls:Skull and Bones:7,spirals:Spirals:26,emblems:Emblems:26,fireflair:Fire Flair:25,razor:Razor:26,batwings:Bat Wings:17,arrows:Arrows:26,sideswipes:Sideswipes:25,flames:Flames:25,fun:Fun:25"');
document.write('sw2="'+site+'"');
document.write('sw3="bg_url-/img/backgrounds/;gallery_url-/gallery/;login_url-/php/login.php;lib_url-/library/;save_url-/php/save.php;flush_url-/php/flush.php;load_url-/php/load.png?id=;app_url-/roofgenerator/roof_builder.dcr;tofriend_url-/php/sendtofriend.php;picker_url-/my_designs/;register_url-/register/;forgetpasswd_url-/forgotpass"');
document.write('sw4=""');
document.write('sw5="99999"');
document.write('sw6="'+site+'dcr/scion.dcr"');
document.write('sw7=""');
document.write('sw8="SOLID COLOR;ABSTRACT;BLUETUNNEL;MOUNTAINS;RUNWAY;WORKSHOP;FOREST;DISCO"');
document.write('sw9="Super White:fcfcfc;Black Sand Pearl:000002;Blackberry Crush Metallic:3f2c28;Nautical Blue Metallic:30384f;Classic Silver Metallic:bdbfbc;Hypnotic Teal Mica:3b4747"');
document.write('type="application/x-director" pluginspage="http://www.macromedia.com/shockwave/download/"></embed>');
document.write('</object>');
}