////////////////////////////////////////////////////////////////////////////
//////////////////////////   tomhatfield.co.uk   ///////////////////////////
///////////////////////////////   SITE.JS   ////////////////////////////////
/////////////////////   © James Brannon Media Design   /////////////////////


//- onload function
$().ready(function() {
	
	//- set swf paramiters
	var flashParams = {
		"menu" : "true",
		"scale" : "noscale",
		"wmode" : "transparent",
		"allowfullscreen" : "true",
		"allowscriptaccess" : "always",
		"base" : "."
	};
	//- embed swf file
	swfobject.embedSWF( "/assets/swf/logo.swf", "logo", "276", "44", "9.0.0", null, null, flashParams, null );
	
	//- swap 'rel' for 'target' to satisfy w3c
	externalLinks();
	
});

//  START: General.  //--------------

//- traget switch (w3c fix)
function externalLinks() {
	if (!document.getElementsByTagName) return;  
	//- add target _blank here to comply with w3c
	var anchors = document.getElementsByTagName("a");  
	for (var i=0; i<anchors.length; i++) {  
		var anchor = anchors[i];  
		if (anchor.getAttribute("href") &&  
       anchor.getAttribute("rel") == "external")  
		anchor.target = "_blank";  
	}
};

//- img switch
function swap( index, total ) {
	
	for ( i=1; i <= total; i++ ) {
		
		if ( i == index ) {
			$( '#photo'+i ).removeClass( "remove" );
			$( '#thumb'+i ).addClass( "active" );
		} else {
		
			$( '#photo'+i ).addClass( "remove" );
			$( '#thumb'+i ).removeClass( "active" );
		
		}
	}

}


//- visibility switch
function visible( id, btn, alt ) {
	
	//- show galleries
	document.getElementById( id ).style.display = "block";
	
	//- switch button with alt
	document.getElementById( alt ).style.display = "inline";
	document.getElementById( btn ).style.display = "none";
	
}

//- confirm function
function confirmPost() {

	var agree=confirm( "Are you sure?" );
	
	if (agree)
		return true ;
	else
		return false ;
}

//  END: General.  //--------------


/////////////////////////////////   END   /////////////////////////////////
///////////////////////////////////////////////////////////////////////////