function is_kingkr_obj() {
    var type = sdk_judge();
    if (type.ios == true) {
        if (typeof window.webkit == 'undefined' || typeof window.webkit.messageHandlers.local_kingkr_obj == 'undefined') {
            return false
        } else {
            return true
        }
    }else{ 
        if (typeof local_kingkr_obj == 'undefined') {
            return false
        } else {
            return true
        }
    }
}
function share(content, imageurl, targetUrl, title) {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        var message = { 'methodName' : 'share', 'content': content,'imageurl': imageurl,'targetUrl': targetUrl,'title': title, 'callbackMethod': 'shareCallback' };
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message);
    }else{
        var share = "{\"content\":\"" + content + "\",\"imageurl\": \"" + imageurl + "\",\"targetUrl\": \"" + targetUrl + "\",\"title\": \"" + title + "\"}";
        local_kingkr_obj.share(share)
    }
}
function openDownLoad() {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        
    }else{
        local_kingkr_obj.openDownLoadFile();
    }
}
function downloadFile(url){
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        
    }else{
        local_kingkr_obj.downloadFile(url);
    }
}
function login(platform, forwardurl, callbackMethod) {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        var message ={'methodName':'login','platform':platform,'forwardurl':forwardurl,'callbackMethod':callbackMethod};
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message);
    }else{
        var login = "{\"platform\":\"" + platform + "\",\"forwardurl\":\"" + forwardurl + "\",\"callbackMethod\":\"" + callbackMethod + "\"}";
        local_kingkr_obj.login(login)
    }
}
function payType(order,paytype,callbackMethod) {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        var message = {'methodName':'pay','order':order,'paytype':paytype,'callbackMethod':callbackMethod};
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message);
    }else{
        var payType = '{"paytype":\"' + paytype + '\","callbackMethod":\"' + callbackMethod + '\"}';
        local_kingkr_obj.payType(order, payType)
    }
}
function audioPlay(operator) {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        
    }else{
        var data = "{\"operator\":" + operator + "}";
        local_kingkr_obj.audioPlay(data);
    }
}
function qrcode() {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        var message = {'methodName':'qrcoder','callbackMethod':'qrcodeCallback'};
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message);
    }else{
        local_kingkr_obj.qrcoderWithCallback();
    }
}
function cleanCache() {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        var message = {'methodName': 'cleancache'};
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message);
    } else {
        local_kingkr_obj.cleanCache();
    }
}
function controlBottomTabLayout(state) {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        var message = {'methodName':'controlBottomTabLayout','show':state};
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message);
    } else {
        local_kingkr_obj.controlBottomTabLayout(state);
    }
}
function controllNavigateLayout(state) {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        var message = {'methodName':'controllNavigateLayout','show':state};
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message);
    } else {
        local_kingkr_obj.controlNavigatorLayout(state);
    }
}
function controlLeftMenuLayout(state) {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        var message = {'methodName':'controlLeftMenuLayout','show':state};
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message);
    } else {
        local_kingkr_obj.controlLeftMenuLayout(state);
    }
}
function getDeviceIdentifier(callbackMethod) {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        var message = {'methodName':'getDeviceIdentifier','callbackMethod':callbackMethod};
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message);
    }else{
        var data = '{"callbackMethod":\"' + callbackMethod + '\"}';
        local_kingkr_obj.getDeviceIndentify(data);
    }
}
function setScreenOrientation(orientation) {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        var message = {'methodName':'setScreenOrientation','orientation':orientation};
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message);
    }else{
        local_kingkr_obj.setScreenOrientation(orientation);
    }
}
function copyUrlToClipboard() {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        var message = {'methodName':'copyUrlToClipboard'};
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message);
    }else{
        local_kingkr_obj.clipboardManager();
    }
}
function awakeOtherBrowser() {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        var message = {'methodName':'awakeOtherWebview'}
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message); 
    }else{
        local_kingkr_obj.awakeOtherWebview(); 
    }
}
function registerPush(token) {
    if(!sdk_checkinside())return false;
    type = sdk_judge();
    if (type.ios == true) {
        var message = {'methodName':'registerPush','token':token};
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message);
    }else{
        local_kingkr_obj.registerPush(token);
    }
}
function getBuild(){
    type = sdk_judge();
    if (type.ios == true) {
        var message = {'methodName':'getBuild','callbackMethod':'getBuildResult'}
        window.webkit.messageHandlers.local_kingkr_obj.postMessage(message);
    }else{
        var b = local_kingkr_obj.getBuild();
        alert(b);
    }
}
function getBuildResult(buildVersion)
{
    alert(buildVersion);
}
function sdk_judge() {
    var u = navigator.userAgent;
    return {
        ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
        android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
    }
}
function sdk_checkinside(){
    if(!is_kingkr_obj()){
        alert("请在App内打开");
        return false;
    }else{
        return true;
    }
}